| Conditions | 5 |
| Paths | 7 |
| Total Lines | 22 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 5 |
| 1 | <?php |
||
| 12 | 12 | public static function validate($data, $parameter, SubSchemaValidatorFactory $validatorFactory, $pointer = null) |
|
| 13 | { |
||
| 14 | 12 | if (!is_array($data)) { |
|
| 15 | 4 | return null; |
|
| 16 | } |
||
| 17 | |||
| 18 | 10 | $errors = []; |
|
| 19 | 10 | foreach ($data as $key => $value) { |
|
| 20 | 10 | $schema = self::getSchema($parameter, $key); |
|
| 21 | |||
| 22 | // Additional items are allowed by default, |
||
| 23 | // so there might not be a schema for this. |
||
| 24 | 10 | if (is_null($schema)) { |
|
| 25 | 2 | continue; |
|
| 26 | } |
||
| 27 | |||
| 28 | 10 | $validator = $validatorFactory->makeSubSchemaValidator($value, $schema, $pointer . '/' . $key); |
|
| 29 | 10 | $errors = array_merge($errors, $validator->errors()); |
|
| 30 | 10 | } |
|
| 31 | |||
| 32 | 10 | return $errors ?: null; |
|
| 33 | } |
||
| 34 | |||
| 54 |