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