Completed
Push — master ( fba866...b10a48 )
by Ori
03:03
created
src/SchemaValidator.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 
39 39
     /**
40 40
      * @param integer $code
41
-     * @param mixed $extraDetails
41
+     * @param string $extraDetails
42 42
      */
43 43
     protected function addError($code, $extraDetails=null)
44 44
     {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      * @param integer $code
41 41
      * @param mixed $extraDetails
42 42
      */
43
-    protected function addError($code, $extraDetails=null)
43
+    protected function addError($code, $extraDetails = null)
44 44
     {
45 45
         $this->errors[] = new SchemaValidationError($code, $extraDetails);
46 46
     }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         $validator = new \JsonSchema\Validator();
52 52
         $validator->validate(
53 53
             $this->descriptor,
54
-                (object)['$ref' => 'file://' . realpath(dirname(__FILE__)).'/schemas/table-schema.json']
54
+                (object)['$ref' => 'file://' . realpath(dirname(__FILE__)) . '/schemas/table-schema.json']
55 55
         );
56 56
         if (!$validator->isValid()) {
57 57
             foreach ($validator->getErrors() as $error) {
Please login to merge, or discard this patch.
src/DataSources/BaseDataSource.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  */
7 7
 abstract class BaseDataSource implements DataSourceInterface
8 8
 {
9
-    public function __construct($dataSource, $options=null)
9
+    public function __construct($dataSource, $options = null)
10 10
     {
11 11
         $this->dataSource = $dataSource;
12 12
         $this->options = empty($options) ? (object)[] : $options;
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     protected $dataSource;
28 28
     protected $options;
29 29
 
30
-    protected function getOption($name, $default=null)
30
+    protected function getOption($name, $default = null)
31 31
     {
32 32
         if (isset($this->options->{$name})) {
33 33
             return $this->options->{$name};
Please login to merge, or discard this patch.
src/Table.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      * @param int $numPeekRows
29 29
      * @return array of validation errors
30 30
      */
31
-    public static function validate($dataSource, $schema, $numPeekRows=10)
31
+    public static function validate($dataSource, $schema, $numPeekRows = 10)
32 32
     {
33 33
         try {
34 34
             $table = new static($dataSource, $schema);
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
 
67 67
     // not interesting, standard iterator functions
68 68
     // to simplify we prevent rewinding - so you can only iterate once
69
-    public function __destruct() {$this->dataSource->close();}
70
-    public function rewind() {if ($this->currentLine == 0) {$this->currentLine = 1;} else {throw new \Exception("rewind is not supported");}}
71
-    public function key() {return $this->currentLine;}
72
-    public function next() {$this->currentLine++;}
73
-    public function valid() {return !$this->dataSource->isEof();}
69
+    public function __destruct() {$this->dataSource->close(); }
70
+    public function rewind() {if ($this->currentLine == 0) {$this->currentLine = 1; } else {throw new \Exception("rewind is not supported"); }}
71
+    public function key() {return $this->currentLine; }
72
+    public function next() {$this->currentLine++; }
73
+    public function valid() {return !$this->dataSource->isEof(); }
74 74
 
75 75
     protected $currentLine = 0;
76 76
     protected $dataSource;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,9 @@
 block discarded – undo
39 39
             $i = 0;
40 40
             try {
41 41
                 foreach ($table as $row) {
42
-                    if (++$i > $numPeekRows) break;
42
+                    if (++$i > $numPeekRows) {
43
+                        break;
44
+                    }
43 45
                 }
44 46
             } catch (Exceptions\DataSourceException $e) {
45 47
                 return [new TableValidationError(TableValidationError::ROW_VALIDATION_FAILED, [
Please login to merge, or discard this patch.
src/SchemaValidationError.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,14 +3,14 @@  discard block
 block discarded – undo
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 9
     /**
10 10
      * @param integer $code
11 11
      * @param mixed $extraDetails
12 12
      */
13
-    public function __construct($code, $extraDetails=null)
13
+    public function __construct($code, $extraDetails = null)
14 14
     {
15 15
         $this->code = $code;
16 16
         $this->extraDetails = $extraDetails;
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public static function getErrorMessages($validationErrors)
42 42
     {
43
-        return implode(", ", array_map(function($validationError){
43
+        return implode(", ", array_map(function($validationError) {
44 44
             /** @var SchemaValidationError $validationError */
45 45
             return $validationError->getMessage();
46 46
         }, $validationErrors));
Please login to merge, or discard this patch.
src/Exceptions/SchemaValidationFailedException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
      */
20 20
     public function __construct($validationErrors)
21 21
     {
22
-        parent::__construct("Schema failed validation: ".SchemaValidationError::getErrorMessages($validationErrors));
22
+        parent::__construct("Schema failed validation: " . SchemaValidationError::getErrorMessages($validationErrors));
23 23
         $this->validationErrors = $validationErrors;
24 24
     }
25 25
 }
Please login to merge, or discard this patch.
src/Exceptions/DataSourceException.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
  */
9 9
 class DataSourceException extends \Exception
10 10
 {
11
-    public function __construct($message, $rowNum=0)
11
+    public function __construct($message, $rowNum = 0)
12 12
     {
13 13
         if (!empty($rowNum)) $message = "row {$rowNum}: {$message}";
14 14
         parent::__construct($message);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@
 block discarded – undo
10 10
 {
11 11
     public function __construct($message, $rowNum=0)
12 12
     {
13
-        if (!empty($rowNum)) $message = "row {$rowNum}: {$message}";
13
+        if (!empty($rowNum)) {
14
+            $message = "row {$rowNum}: {$message}";
15
+        }
14 16
         parent::__construct($message);
15 17
     }
16 18
 }
Please login to merge, or discard this patch.
src/Exceptions/SchemaLoadException.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@
 block discarded – undo
14 14
     public function __construct($descriptor, $descriptorSource, $errorMessage)
15 15
     {
16 16
         if (!empty($descriptor) && empty($descriptorSource)) {
17
-            $message = "error decoding descriptor ".json_encode($descriptor).": {$errorMessage}";
17
+            $message = "error decoding descriptor " . json_encode($descriptor) . ": {$errorMessage}";
18 18
         } elseif (!empty($descriptor) && !empty($descriptorSource)) {
19
-            $message = "error decoding descriptor from source ".json_encode($descriptorSource)
20
-                ." - ".json_encode($descriptor).": {$errorMessage}";
19
+            $message = "error decoding descriptor from source " . json_encode($descriptorSource)
20
+                ." - " . json_encode($descriptor) . ": {$errorMessage}";
21 21
         } elseif (empty($descriptor) && !empty($descriptorSource)) {
22
-            $message = "error loading descriptor from source ".json_encode($descriptorSource)
22
+            $message = "error loading descriptor from source " . json_encode($descriptorSource)
23 23
                 .": {$errorMessage}";
24 24
         } else {
25 25
             $message = "unexpected load error: {$errorMessage}";
Please login to merge, or discard this patch.