| Conditions | 3 |
| Paths | 3 |
| Total Lines | 13 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 3 |
| 1 | <?php |
||
| 14 | 6 | public static function validate($value, $parameter, $pointer = null) |
|
| 15 | { |
||
| 16 | 6 | if (!is_array($value)) { |
|
| 17 | 2 | return null; |
|
| 18 | } |
||
| 19 | |||
| 20 | 4 | if (count($value) === count(array_unique(array_map('serialize', $value)))) { |
|
| 21 | 4 | return null; |
|
| 22 | } |
||
| 23 | |||
| 24 | 2 | $message = sprintf('Array "%s" is not unique.', JsonGuard\asString($value)); |
|
| 25 | 2 | return new ValidationError($message, ErrorCode::NOT_UNIQUE_ITEM, $value, $pointer); |
|
| 26 | } |
||
| 27 | } |
||
| 28 |