Conditions | 6 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
17 | 8 | public function validate($value, $parameter, Validator $validator) |
|
18 | { |
||
19 | 8 | Assert::type($parameter, 'array', self::KEYWORD, $validator->getSchemaPath()); |
|
20 | |||
21 | 4 | if (is_object($value)) { |
|
22 | 2 | foreach ($parameter as $i) { |
|
23 | 2 | if (is_object($i) && $value == $i) { |
|
24 | 2 | return null; |
|
25 | } |
||
26 | } |
||
27 | } else { |
||
28 | 4 | if (in_array($value, $parameter, true)) { |
|
29 | 4 | return null; |
|
30 | } |
||
31 | } |
||
32 | |||
33 | 4 | return error('The value must be one of: {parameter}', $validator); |
|
34 | } |
||
35 | } |
||
36 |