Conditions | 6 |
Paths | 4 |
Total Lines | 24 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 6.0073 |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
16 | 12 | public function validate($value, $parameter, Validator $validator) |
|
17 | { |
||
18 | 12 | Assert::type($parameter, 'array', self::KEYWORD, $validator->getPointer()); |
|
19 | |||
20 | 8 | if (is_object($value)) { |
|
21 | 4 | foreach ($parameter as $i) { |
|
22 | 4 | if (is_object($i) && $value == $i) { |
|
23 | return null; |
||
24 | } |
||
25 | 4 | } |
|
26 | 4 | } else { |
|
27 | 8 | if (in_array($value, $parameter, true)) { |
|
28 | 8 | return null; |
|
29 | } |
||
30 | } |
||
31 | |||
32 | 8 | return new ValidationError( |
|
33 | 8 | 'Value {value} is not one of: {choices}', |
|
34 | 8 | self::KEYWORD, |
|
35 | 8 | $value, |
|
36 | 8 | $validator->getPointer(), |
|
37 | 8 | ['choices' => $parameter, 'value' => $value] |
|
38 | 8 | ); |
|
39 | } |
||
40 | } |
||
41 |