| Conditions | 3 |
| Paths | 3 |
| Total Lines | 23 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 3.0021 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 20 | public static function validate($data, $parameter, $pointer = null) |
|
| 16 | { |
||
| 17 | 20 | Assert::type($parameter, 'array', self::KEYWORD, $pointer); |
|
| 18 | 18 | Assert::notEmpty($parameter, self::KEYWORD, $pointer); |
|
| 19 | |||
| 20 | 16 | if (!is_object($data)) { |
|
| 21 | return null; |
||
| 22 | } |
||
| 23 | |||
| 24 | 16 | $actualProperties = array_keys(get_object_vars($data)); |
|
| 25 | 16 | $missing = array_diff($parameter, $actualProperties); |
|
| 26 | 16 | if (count($missing)) { |
|
| 27 | 14 | return new ValidationError( |
|
| 28 | 14 | 'Required properties missing: {missing}', |
|
| 29 | 14 | self::KEYWORD, |
|
| 30 | 14 | $data, |
|
| 31 | 14 | $pointer, |
|
| 32 | 14 | ['missing' => array_values($missing)] |
|
| 33 | 14 | ); |
|
| 34 | } |
||
| 35 | |||
| 36 | 14 | return null; |
|
| 37 | } |
||
| 38 | } |
||
| 39 |