| Conditions | 5 |
| Paths | 7 |
| Total Lines | 25 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 18 |
| CRAP Score | 5.0035 |
| 1 | <?php |
||
| 14 | 2 | public static function validate($data, $parameter, SubSchemaValidatorFactory $validatorFactory, $pointer = null) |
|
| 15 | { |
||
| 16 | 2 | if (!is_array($parameter)) { |
|
| 17 | return null; |
||
| 18 | } |
||
| 19 | |||
| 20 | 2 | $passed = 0; |
|
| 21 | 2 | foreach ($parameter as $schema) { |
|
| 22 | 2 | $validator = $validatorFactory->makeSubSchemaValidator($data, $schema, $pointer); |
|
| 23 | 2 | if ($validator->passes()) { |
|
| 24 | 2 | $passed++; |
|
| 25 | 2 | } |
|
| 26 | 2 | } |
|
| 27 | 2 | if ($passed !== 1) { |
|
| 28 | 2 | return new ValidationError( |
|
| 29 | 2 | 'Failed matching exactly one of the provided schemas.', |
|
| 30 | 2 | ErrorCode::ONE_OF_SCHEMA, |
|
| 31 | 2 | $data, |
|
| 32 | 2 | $pointer, |
|
| 33 | 2 | ['one_of' => $parameter] |
|
| 34 | 2 | ); |
|
| 35 | } |
||
| 36 | |||
| 37 | 2 | return null; |
|
| 38 | } |
||
| 39 | } |
||
| 40 |