Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
20 | public function validate(Json $json, Validator $validator, RefResolver $refResolver) |
||
21 | { |
||
22 | $schema = $refResolver->resolve('file://' . realpath($this->filename)); |
||
23 | |||
24 | $validator->check($json->getRawContent(), $schema); |
||
25 | |||
26 | if (!$validator->isValid()) { |
||
27 | $msg = "JSON does not validate. Violations:" . PHP_EOL; |
||
28 | foreach ($validator->getErrors() as $error) { |
||
29 | $msg .= sprintf(" - [%s] %s" . PHP_EOL, $error['property'], $error['message']); |
||
30 | } |
||
31 | throw new \Exception($msg); |
||
32 | } |
||
33 | |||
34 | return true; |
||
35 | } |
||
36 | } |
||
37 |