Lines
100.00%
32 / 32
Methods
100.00%
22 / 22
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| [Stewart\Contracts\Registry\Collection\RegistryIdCollection] contains | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Contracts\Registry\Collection\RegistryIdCollection] containsAnyOf | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Contracts\Registry\Collection\RegistryIdCollection] withAddedMembers | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 3 | ||
| [Stewart\Contracts\Registry\Collection\RegistryIdCollection] withoutMembers | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Contracts\Registry\Collection\RegistryIdCollection] toStrings | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Contracts\Collection\ListCollection] fromList | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 2 | ||
| [Stewart\Contracts\Collection\ListCollection] withAppendedElement | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Contracts\Collection\ListCollection] arrangeElements | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Contracts\Collection\TypedCollection] __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Contracts\Collection\TypedCollection] empty | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Contracts\Collection\TypedCollection] count | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Contracts\Collection\TypedCollection] isEmpty | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Contracts\Collection\TypedCollection] getFirst | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 2 | ||
| [Stewart\Contracts\Collection\TypedCollection] getLast | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 2 | ||
| [Stewart\Contracts\Collection\TypedCollection] listValues | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Contracts\Collection\TypedCollection] filter | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Contracts\Collection\TypedCollection] mapToList | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Contracts\Collection\TypedCollection] containsWhere | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Contracts\Collection\TypedCollection] findFirstWhere | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Contracts\Collection\TypedCollection] sortedBy | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Contracts\Collection\TypedCollection] getIterator | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Stewart\Contracts\Collection\TypedCollection] elements | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| 13 | final readonly class DeviceIdCollection extends RegistryIdCollection {} |
Inherited from Stewart\Contracts\Registry\Collection\RegistryIdCollection
| 17 | public function contains(RegistryId $id): bool | |
| 18 | { | |
| 19 | return $this->containsWhere(static fn(RegistryId $member): bool => $member->equals($id)); | |
| 20 | } |
| 23 | public function containsAnyOf(self $other): bool | |
| 24 | { | |
| 25 | return $other->containsWhere($this->contains(...)); | |
| 26 | } |
| 29 | public function withAddedMembers(self $ids): static | |
| 30 | { | |
| 31 | $merged = $this; | |
| 32 | ||
| 33 | foreach ($ids as $id) { | |
| 34 | $merged = $merged->contains($id) ? $merged : $merged->withAppendedElement($id); | |
| 35 | } | |
| 36 | ||
| 37 | return $merged; | |
| 38 | } |
| 41 | public function withoutMembers(self $ids): static | |
| 42 | { | |
| 43 | return $this->filter(static fn(RegistryId $id): bool => !$ids->contains($id)); | |
| 44 | } |
| 47 | public function toStrings(): array | |
| 48 | { | |
| 49 | return $this->mapToList(static fn(RegistryId $id): string => $id->value); | |
| 50 | } |
Inherited from Stewart\Contracts\Collection\ListCollection
| 14 | public static function fromList(iterable $elements): static | |
| 15 | { | |
| 16 | $list = []; | |
| 17 | ||
| 18 | foreach ($elements as $element) { | |
| 19 | $list[] = $element; | |
| 20 | } | |
| 21 | ||
| 22 | return new static($list); | |
| 23 | } |
| 26 | protected function withAppendedElement(mixed $element): static | |
| 27 | { | |
| 28 | return new static([...$this->elements(), $element]); | |
| 29 | } |
| 35 | protected function arrangeElements(array $elements): array | |
| 36 | { | |
| 37 | return array_values($elements); | |
| 38 | } |
Inherited from Stewart\Contracts\Collection\TypedCollection
| 21 | final protected function __construct(private array $elements = []) {} |
| 23 | public static function empty(): static | |
| 24 | { | |
| 25 | return new static(); | |
| 26 | } |
| 28 | public function count(): int | |
| 29 | { | |
| 30 | return \count($this->elements); | |
| 31 | } |
| 33 | public function isEmpty(): bool | |
| 34 | { | |
| 35 | return $this->elements === []; | |
| 36 | } |
| 39 | public function getFirst(): mixed | |
| 40 | { | |
| 41 | $key = array_key_first($this->elements); | |
| 42 | ||
| 43 | return $key === null ? null : $this->elements[$key]; | |
| 44 | } |
| 47 | public function getLast(): mixed | |
| 48 | { | |
| 49 | $key = array_key_last($this->elements); | |
| 50 | ||
| 51 | return $key === null ? null : $this->elements[$key]; | |
| 52 | } |
| 55 | public function listValues(): array | |
| 56 | { | |
| 57 | return array_values($this->elements); | |
| 58 | } |
| 61 | public function filter(Closure $predicate): static | |
| 62 | { | |
| 63 | return new static($this->arrangeElements(array_filter($this->elements, $predicate))); | |
| 64 | } |
| 71 | public function mapToList(Closure $transform): array | |
| 72 | { | |
| 73 | return array_values(array_map($transform, $this->elements)); | |
| 74 | } |
| 77 | public function containsWhere(Closure $predicate): bool | |
| 78 | { | |
| 79 | return array_any($this->elements, $predicate); | |
| 80 | } |
| 86 | public function findFirstWhere(Closure $predicate): mixed | |
| 87 | { | |
| 88 | return array_find($this->elements, $predicate); | |
| 89 | } |
| 92 | public function sortedBy(Closure $comparator): static | |
| 93 | { | |
| 94 | $sorted = $this->elements; | |
| 95 | uasort($sorted, $comparator); | |
| 96 | ||
| 97 | return new static($this->arrangeElements($sorted)); | |
| 98 | } |
| 101 | public function getIterator(): Traversable | |
| 102 | { | |
| 103 | return new ArrayIterator($this->elements); | |
| 104 | } |
| 113 | protected function elements(): array | |
| 114 | { | |
| 115 | return $this->elements; | |
| 116 | } |