These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace League\JsonGuard\Constraints; |
||
4 | |||
5 | use League\JsonGuard\SubSchemaValidatorFactory; |
||
6 | |||
7 | class AllOf implements ContainerInstanceConstraint |
||
8 | { |
||
9 | const KEYWORD = 'allOf'; |
||
10 | |||
11 | /** |
||
12 | * {@inheritdoc} |
||
13 | */ |
||
14 | 10 | public static function validate($data, $parameter, SubSchemaValidatorFactory $validatorFactory, $pointer = null) |
|
15 | { |
||
16 | 10 | if (!is_array($parameter)) { |
|
17 | 2 | return null; |
|
18 | } |
||
19 | |||
20 | 8 | $errors = []; |
|
21 | |||
22 | 8 | View Code Duplication | foreach ($parameter as $schema) { |
0 ignored issues
–
show
|
|||
23 | 8 | $validator = $validatorFactory->makeSubSchemaValidator($data, $schema, $pointer); |
|
24 | 8 | $errors = array_merge($errors, $validator->errors()); |
|
25 | 8 | } |
|
26 | |||
27 | 8 | return $errors; |
|
28 | } |
||
29 | } |
||
30 |
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.