| Total Complexity | 5 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class JsonValidator implements ValidatorInterface |
||
| 11 | { |
||
| 12 | public $definitions = null; |
||
| 13 | public $schema = null; |
||
| 14 | public $schema_url = null; |
||
| 15 | |||
| 16 | public function setSchema($schema, $schema_url=null, $definitions=null) { |
||
| 20 | } |
||
| 21 | |||
| 22 | |||
| 23 | public function validate($msg) |
||
| 24 | { |
||
| 25 | try{ |
||
| 26 | $options = new Context(); |
||
| 27 | |||
| 28 | if ($this->definitions != null) { |
||
| 29 | $refProvider = new Preloaded(); |
||
| 30 | $refProvider->setSchemaData($this->schema_url, json_decode(file_get_contents($this->definitions, true))); |
||
| 31 | $options->remoteRefProvider = $refProvider; |
||
| 32 | } |
||
| 33 | |||
| 34 | $schema = Schema::import(json_decode(file_get_contents($this->schema, true)), $options); |
||
| 35 | $schema->in(json_decode($msg)); |
||
| 36 | return null; |
||
| 37 | }catch (Exception $e){ |
||
| 38 | return $e->getMessage(); |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | public function getContentType() { |
||
| 44 | } |
||
| 45 | } |
||
| 46 |