Conditions | 6 |
Paths | 5 |
Total Lines | 23 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 6 |
1 | <?php |
||
12 | 28 | public static function validate($data, $parameter, SubSchemaValidatorFactory $validatorFactory, $pointer = null) |
|
13 | { |
||
14 | 28 | if (!is_object($data)) { |
|
15 | 8 | return null; |
|
16 | } |
||
17 | |||
18 | // Iterate through the properties and create a new |
||
19 | // validator for that property's schema and data. |
||
20 | // merge the errors. |
||
21 | 28 | $errors = []; |
|
22 | 28 | foreach ($parameter as $property => $schema) { |
|
23 | 28 | if (is_object($data) && property_exists($data, $property)) { |
|
24 | 28 | $propertyData = $data->$property; |
|
25 | 28 | $propertyPointer = $pointer . '/' . $property; |
|
26 | 28 | $validator = $validatorFactory->makeSubSchemaValidator($propertyData, $schema, $propertyPointer); |
|
27 | 28 | if ($validator->fails()) { |
|
28 | 20 | $errors = array_merge($errors, $validator->errors()); |
|
29 | 20 | } |
|
30 | 26 | } |
|
31 | 26 | } |
|
32 | |||
33 | 26 | return $errors; |
|
34 | } |
||
35 | } |
||
36 |