Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| InMemoryEntityList | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getIterator | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getTotalCount | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\Core\Datalayers\Lists; |
| 3 | |
| 4 | use Apie\Core\BoundedContext\BoundedContextId; |
| 5 | use Apie\Core\Datalayers\Concerns\CreatePaginatedResultRuntime; |
| 6 | use Apie\Core\Datalayers\Search\LazyLoadedListFilterer; |
| 7 | use Apie\Core\Entities\EntityInterface; |
| 8 | use ArrayIterator; |
| 9 | use Iterator; |
| 10 | use ReflectionClass; |
| 11 | |
| 12 | /** |
| 13 | * @template T of EntityInterface |
| 14 | * @implements EntityListInterface<T> |
| 15 | */ |
| 16 | class InMemoryEntityList implements EntityListInterface |
| 17 | { |
| 18 | use CreatePaginatedResultRuntime; |
| 19 | |
| 20 | /** |
| 21 | * @param ReflectionClass<T> $class |
| 22 | * @param array<int, T> $entityList |
| 23 | */ |
| 24 | public function __construct( |
| 25 | private ReflectionClass $class, |
| 26 | private BoundedContextId $boundedContextId, |
| 27 | private LazyLoadedListFilterer $filterer, |
| 28 | private array& $entityList |
| 29 | ) { |
| 30 | } |
| 31 | |
| 32 | public function getIterator(): Iterator |
| 33 | { |
| 34 | return new ArrayIterator($this->entityList); |
| 35 | } |
| 36 | |
| 37 | public function getTotalCount(): int |
| 38 | { |
| 39 | return count($this->entityList); |
| 40 | } |
| 41 | } |