-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrix.php
More file actions
41 lines (34 loc) · 1.08 KB
/
Matrix.php
File metadata and controls
41 lines (34 loc) · 1.08 KB
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
38
39
40
41
<?php
declare(strict_types=1);
namespace TypistTech\PhpMatrix\Matrices;
use Composer\Semver\Semver;
use Composer\Semver\VersionParser;
use TypistTech\PhpMatrix\Exceptions\UnexpectedValueException as AppUnexpectedValueException;
use TypistTech\PhpMatrix\Releases\ReleasesInterface;
use UnexpectedValueException;
readonly class Matrix implements MatrixInterface
{
public function __construct(
private ReleasesInterface $releases,
private VersionParser $versionParser = new VersionParser(),
) {}
/**
* @return string[]
*/
public function satisfiedBy(string $constraint): array
{
try {
// Validate constraint before passing to Semver::satisfiedBy();
$this->versionParser->parseConstraints($constraint);
return Semver::satisfiedBy(
$this->releases->all(),
$constraint
);
} catch (UnexpectedValueException $e) {
throw new AppUnexpectedValueException(
$e->getMessage(),
previous: $e
);
}
}
}