| Conditions | 6 |
| Paths | 15 |
| Total Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 0 | ||
| 1 | <?php |
||
| 40 | public function validate(Collection $collection) |
||
| 41 | { |
||
| 42 | foreach ($collection->getIterator() as $entity) { |
||
| 43 | if (is_null($entity->getValidator())) { |
||
| 44 | continue; |
||
| 45 | } |
||
| 46 | |||
| 47 | $filter = $this->filter->newSubjectFilter($entity->getValidator()); |
||
| 48 | |||
| 49 | try { |
||
| 50 | $data = $entity->getData([], false); |
||
| 51 | |||
| 52 | foreach (array_keys($entity->getMapping()) as $property) { |
||
| 53 | $data[$property] = (array_key_exists($property, $data)) ? $data[$property] : null; |
||
| 54 | } |
||
| 55 | |||
| 56 | $filter($data); |
||
| 57 | } catch (FilterFailed $e) { |
||
| 58 | $exception = new ValidationException($e->getMessage()); |
||
| 59 | $exception->setFailures($e->getFailures()->getMessages()); |
||
| 60 | |||
| 61 | throw $exception; |
||
| 62 | } |
||
| 63 | } |
||
| 64 | |||
| 65 | return true; |
||
| 66 | } |
||
| 67 | } |
||
| 68 |