Lines
100.00%
2 / 2
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| SelectorCollection | 100.00% | 2 / 2 | 100.00% | 2 / 2 | 2 | 100.00% | 1 / 1 | |||
| fromSpecs | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| anyMatches | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Contracts\Selector\Collection; | |
| 6 | ||
| 7 | use Stewart\Contracts\Collection\ListCollection; | |
| 8 | use Stewart\Contracts\Entity\EntityId; | |
| 9 | use Stewart\Contracts\Exception\SelectorException; | |
| 10 | use Stewart\Contracts\Selector\Selector; | |
| 11 | ||
| 12 | /** @extends ListCollection<Selector> */ | |
| 13 | final readonly class SelectorCollection extends ListCollection | |
| 14 | { | |
| 15 | /** @throws SelectorException */ | |
| 16 | public static function fromSpecs(string|EntityId|Selector ...$specs): self | |
| 17 | { | |
| 18 | return self::fromList(array_map(Selector::fromSpec(...), $specs)); | |
| 19 | } | |
| 20 | ||
| 21 | public function anyMatches(string $candidate): bool | |
| 22 | { | |
| 23 | return $this->containsWhere(static fn(Selector $selector): bool => $selector->matches($candidate)); | |
| 24 | } | |
| 25 | } |