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
3declare(strict_types=1);
4
5namespace Stewart\Contracts\Selector\Collection;
6
7use Stewart\Contracts\Collection\ListCollection;
8use Stewart\Contracts\Entity\EntityId;
9use Stewart\Contracts\Exception\SelectorException;
10use Stewart\Contracts\Selector\Selector;
11
12/** @extends ListCollection<Selector> */
13final 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}