-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVersions.php
More file actions
37 lines (28 loc) · 775 Bytes
/
Versions.php
File metadata and controls
37 lines (28 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
declare(strict_types=1);
namespace TypistTech\PhpMatrix;
use Composer\Semver\Semver;
use UnexpectedValueException;
readonly class Versions
{
/**
* @return string[]
*/
public static function sort(string ...$versions): array
{
if ($versions === []) {
throw new UnexpectedValueException('Argument #1 ($versions) must not be empty');
}
return Semver::sort($versions);
}
public static function lowest(string ...$versions): string
{
$sorted = self::sort(...$versions);
return (string) array_first($sorted);
}
public static function highest(string ...$versions): string
{
$sorted = self::sort(...$versions);
return (string) array_last($sorted);
}
}