@@ -10,6 +10,9 @@ |
||
| 10 | 10 | $this->errors = []; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | + /** |
|
| 14 | + * @param string $extraDetails |
|
| 15 | + */ |
|
| 13 | 16 | protected function _addError($code, $extraDetails=null) |
| 14 | 17 | { |
| 15 | 18 | $this->errors[] = new SchemaValidationError($code, $extraDetails); |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | $this->errors = []; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | - protected function _addError($code, $extraDetails=null) |
|
| 13 | + protected function _addError($code, $extraDetails = null) |
|
| 14 | 14 | { |
| 15 | 15 | $this->errors[] = new SchemaValidationError($code, $extraDetails); |
| 16 | 16 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | { |
| 20 | 20 | // Validate |
| 21 | 21 | $validator = new \JsonSchema\Validator(); |
| 22 | - $validator->validate($this->descriptor, (object)['$ref' => 'file://' . realpath(dirname(__FILE__)).'/schemas/table-schema.json']); |
|
| 22 | + $validator->validate($this->descriptor, (object)['$ref' => 'file://' . realpath(dirname(__FILE__)) . '/schemas/table-schema.json']); |
|
| 23 | 23 | if (!$validator->isValid()) { |
| 24 | 24 | foreach ($validator->getErrors() as $error) { |
| 25 | 25 | $this->_addError(SchemaValidationError::SCHEMA_VIOLATION, sprintf("[%s] %s", $error['property'], $error['message'])); |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | if (count($this->validationErrors) == 0) { |
| 19 | 19 | $this->descriptor = $descriptor; |
| 20 | 20 | } else { |
| 21 | - throw new SchemaException("descriptor failed validation: ".SchemaValidationError::getErrorMessages($this->validationErrors)); |
|
| 21 | + throw new SchemaException("descriptor failed validation: " . SchemaValidationError::getErrorMessages($this->validationErrors)); |
|
| 22 | 22 | }; |
| 23 | 23 | } |
| 24 | 24 | |
@@ -3,10 +3,10 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | class SchemaValidationError { |
| 5 | 5 | |
| 6 | - const LOAD_FAILED=1; |
|
| 7 | - const SCHEMA_VIOLATION=8; |
|
| 6 | + const LOAD_FAILED = 1; |
|
| 7 | + const SCHEMA_VIOLATION = 8; |
|
| 8 | 8 | |
| 9 | - public function __construct($code, $extraDetails=null) |
|
| 9 | + public function __construct($code, $extraDetails = null) |
|
| 10 | 10 | { |
| 11 | 11 | $this->code = $code; |
| 12 | 12 | $this->extraDetails = $extraDetails; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | public static function getErrorMessages($validationErrors) |
| 28 | 28 | { |
| 29 | - return implode(", ", array_map(function($validation_error){ |
|
| 29 | + return implode(", ", array_map(function($validation_error) { |
|
| 30 | 30 | return $validation_error->getMessage(); |
| 31 | 31 | }, $validationErrors)); |
| 32 | 32 | } |