| Total Complexity | 12 |
| Total Lines | 81 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class ArrayObjectDataRepository extends BasicObjectDataRepository |
||
| 11 | { |
||
| 12 | /** @var ArrayCollection */ |
||
| 13 | private $objects; |
||
| 14 | |||
| 15 | 25 | public function __construct( |
|
| 16 | ObjectManagerInterface $objectManager, |
||
| 17 | ArrayCollection $objects, |
||
| 18 | string $className |
||
| 19 | ) { |
||
| 20 | 25 | parent::__construct($objectManager, $className); |
|
| 21 | 25 | $this->objects = $objects; |
|
| 22 | 25 | } |
|
| 23 | |||
| 24 | /** |
||
| 25 | * @return mixed[][] |
||
| 26 | */ |
||
| 27 | 2 | public function findAll() : array |
|
| 28 | { |
||
| 29 | 2 | return $this->objects->toArray(); |
|
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param mixed[] $criteria |
||
| 34 | * @param mixed[] $orderBy |
||
| 35 | * |
||
| 36 | * @return mixed[][] |
||
| 37 | */ |
||
| 38 | 2 | public function findBy( |
|
| 39 | array $criteria, |
||
| 40 | ?array $orderBy = null, |
||
| 41 | ?int $limit = null, |
||
| 42 | ?int $offset = null |
||
| 43 | ) : array { |
||
| 44 | 2 | $objects = []; |
|
| 45 | |||
| 46 | 2 | foreach ($this->objects as $object) { |
|
| 47 | 2 | $matches = true; |
|
| 48 | |||
| 49 | 2 | foreach ($criteria as $key => $value) { |
|
| 50 | 2 | if ($object[$key] === $value) { |
|
| 51 | 2 | continue; |
|
| 52 | } |
||
| 53 | |||
| 54 | 1 | $matches = false; |
|
| 55 | } |
||
| 56 | |||
| 57 | 2 | if (! $matches) { |
|
| 58 | 1 | continue; |
|
| 59 | } |
||
| 60 | |||
| 61 | 2 | $objects[] = $object; |
|
| 62 | } |
||
| 63 | |||
| 64 | 2 | return $objects; |
|
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @param mixed[] $criteria |
||
| 69 | * |
||
| 70 | * @return mixed[]|null |
||
| 71 | */ |
||
| 72 | 19 | public function findOneBy(array $criteria) : ?array |
|
| 91 | } |
||
| 92 | } |
||
| 93 |