Conditions | 3 |
Paths | 3 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
17 | public function validate($value, $parameter, Validator $validator) |
||
18 | { |
||
19 | Assert::type($parameter, 'array', self::KEYWORD, $validator->getSchemaPath()); |
||
20 | Assert::notEmpty($parameter, self::KEYWORD, $validator->getSchemaPath()); |
||
21 | |||
22 | if (!is_object($value)) { |
||
23 | return null; |
||
24 | } |
||
25 | |||
26 | $actualProperties = array_keys(get_object_vars($value)); |
||
27 | $missing = array_diff($parameter, $actualProperties); |
||
28 | if (count($missing)) { |
||
29 | return error('The object must contain the properties {cause}.', $validator) |
||
30 | ->withCause(array_values($missing)); |
||
31 | } |
||
32 | |||
33 | return null; |
||
34 | } |
||
35 | } |
||
36 |