Conditions | 4 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
17 | 8 | public function validate($value, $parameter, Validator $validator) |
|
18 | { |
||
19 | 8 | Assert::type($parameter, 'boolean', self::KEYWORD, $validator->getSchemaPath()); |
|
20 | |||
21 | 6 | if (!is_array($value) || $parameter === false) { |
|
22 | 2 | return null; |
|
23 | } |
||
24 | |||
25 | 4 | if (count($value) === count(array_unique(array_map('serialize', $value)))) { |
|
26 | 4 | return null; |
|
27 | } |
||
28 | |||
29 | 2 | return error('The array must be unique.', $validator); |
|
30 | } |
||
31 | } |
||
32 |