| Conditions | 2 |
| Paths | 1 |
| Total Lines | 26 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 19 | protected function validate($input): EntityList |
||
| 20 | { |
||
| 21 | $name = $this->getName(); |
||
| 22 | |||
| 23 | Assert::that($input) |
||
| 24 | ->isArray('Must be an array.') |
||
| 25 | ->satisfy(function (array $items) use ($name): void { |
||
| 26 | $formatAssertion = Assert::lazy(); |
||
| 27 | $typeAssertion = Assert::lazy(); |
||
| 28 | foreach ($items as $index => $item) { |
||
| 29 | $formatAssertion |
||
| 30 | ->that($item, $name) |
||
| 31 | ->isArray($name."[$index] must be an array.") |
||
| 32 | ->notEmpty($name."[$index] must not be empty."); |
||
| 33 | $typeAssertion |
||
| 34 | ->that($item, $name) |
||
| 35 | ->keyExists( |
||
| 36 | EntityInterface::TYPE_KEY, |
||
| 37 | 'Required input for '.$name."[$index] '".EntityInterface::TYPE_KEY."' is missing." |
||
| 38 | ); |
||
| 39 | } |
||
| 40 | $formatAssertion->verifyNow(); |
||
| 41 | $typeAssertion->verifyNow(); |
||
| 42 | }); |
||
| 43 | |||
| 44 | return EntityList::fromNative($input); |
||
| 45 | } |
||
| 47 |