Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 13 |
Lines | 6 |
Ratio | 31.58 % |
Tests | 15 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
16 | 10 | public static function validate($data, $parameter, SubSchemaValidatorFactory $validatorFactory, $pointer = null) |
|
17 | { |
||
18 | 10 | Assert::type($parameter, 'array', self::KEYWORD, $pointer); |
|
19 | 8 | Assert::notEmpty($parameter, self::KEYWORD, $pointer); |
|
20 | |||
21 | 8 | View Code Duplication | foreach ($parameter as $schema) { |
|
|||
22 | 8 | $validator = $validatorFactory->makeSubSchemaValidator($data, $schema, $pointer); |
|
23 | 8 | if ($validator->passes()) { |
|
24 | 8 | return null; |
|
25 | } |
||
26 | 8 | } |
|
27 | 8 | return new ValidationError( |
|
28 | 8 | 'Failed matching any of the provided schemas.', |
|
29 | 8 | self::KEYWORD, |
|
30 | 8 | $data, |
|
31 | 8 | $pointer, |
|
32 | 8 | ['any_of' => $parameter] |
|
33 | 8 | ); |
|
34 | } |
||
35 | } |
||
36 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.