Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
InMemoryEntityList
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getIterator
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getTotalCount
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\Core\Datalayers\Lists;
3
4use Apie\Core\BoundedContext\BoundedContextId;
5use Apie\Core\Datalayers\Concerns\CreatePaginatedResultRuntime;
6use Apie\Core\Datalayers\Search\LazyLoadedListFilterer;
7use Apie\Core\Entities\EntityInterface;
8use ArrayIterator;
9use Iterator;
10use ReflectionClass;
11
12/**
13 * @template T of EntityInterface
14 * @implements EntityListInterface<T>
15 */
16class 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}