Conditions | 4 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | public function validate(): ValidationResultsInterface |
||
20 | { |
||
21 | $resultCollector = new ValidationResultsCollectorImpl(); |
||
22 | |||
23 | foreach ($this->validators as $validator) { |
||
24 | $elementType = $validator->getElementType(); |
||
25 | $modelElementsByType = $modelInstanceImpl->getModelElementsByType($elementType); |
||
|
|||
26 | |||
27 | foreach ($modelElementsByType as $element) { |
||
28 | $resultCollector->setCurrentElement($element); |
||
29 | |||
30 | try { |
||
31 | $validator->validate($element, $resultCollector); |
||
32 | } catch (\Exception $e) { |
||
33 | throw new Exception("validator threw an exception while validating an element"); |
||
34 | } |
||
35 | } |
||
36 | } |
||
37 | |||
38 | return $resultsCollector->getResults(); |
||
39 | } |
||
41 |