Lines 100.00% 3 / 3
Functions and Methods 100.00% 2 / 2
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
RecordedRegistryUpdateCollection 100.00% 3 / 3 100.00% 2 / 2 2 100.00% 1 / 1
 withRecordedUpdate 100.00% 1 / 1 100.00% 1 / 1 1
 filterByEntityId 100.00% 2 / 2 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Testing\Registry\Collection;
6
7use Stewart\Contracts\Collection\ListCollection;
8use Stewart\Contracts\Entity\EntityId;
9use Stewart\Testing\Registry\RecordedRegistryUpdate;
10
11/** @extends ListCollection<RecordedRegistryUpdate> */
12final readonly class RecordedRegistryUpdateCollection extends ListCollection
13{
14    public function withRecordedUpdate(RecordedRegistryUpdate $update): self
15    {
16        return $this->withAppendedElement($update);
17    }
18
19    public function filterByEntityId(EntityId|string $entityId): self
20    {
21        $entityId = EntityId::fromStringOrId($entityId);
22
23        return $this->filter(static fn(RecordedRegistryUpdate $update): bool => $update->entityId->equals($entityId));
24    }
25}