Completed
Push — master ( b10a48...29cde4 )
by Ori
05:27
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/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.
src/SchemaValidationError.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
 
4 4
 class SchemaValidationError
5 5
 {
6
-    const LOAD_FAILED=1;
7
-    const SCHEMA_VIOLATION=8;
8
-    const FIELD_VALIDATION=21;
9
-    const ROW_FIELD_VALIDATION=22;
10
-    const ROW_VALIDATION=23;
6
+    const LOAD_FAILED = 1;
7
+    const SCHEMA_VIOLATION = 8;
8
+    const FIELD_VALIDATION = 21;
9
+    const ROW_FIELD_VALIDATION = 22;
10
+    const ROW_VALIDATION = 23;
11 11
 
12 12
     public $code;
13 13
     public $extraDetails;
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
      * @param integer $code
17 17
      * @param mixed $extraDetails
18 18
      */
19
-    public function __construct($code, $extraDetails=null)
19
+    public function __construct($code, $extraDetails = null)
20 20
     {
21 21
         $this->code = $code;
22 22
         $this->extraDetails = $extraDetails;
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public static function getErrorMessages($validationErrors)
63 63
     {
64
-        return implode(", ", array_map(function($validationError){
64
+        return implode(", ", array_map(function($validationError) {
65 65
             /** @var SchemaValidationError $validationError */
66 66
             return $validationError->getMessage();
67 67
         }, $validationErrors));
Please login to merge, or discard this patch.
src/InferSchema.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
 class InferSchema extends Schema
8 8
 {
9
-    public function __construct($descriptor=null, $lenient=false)
9
+    public function __construct($descriptor = null, $lenient = false)
10 10
     {
11 11
         $this->descriptor = empty($descriptor) ? (object)["fields" => []] : $descriptor;
12 12
         $this->fieldsInferer = new Fields\FieldsInferrer(null, $lenient);
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
                 $this->descriptor->fields[] = $inferredField->descriptor();
40 40
             }
41 41
             $this->castRows = $this->fieldsInferer->castRows();
42
-            return $this->castRows[count($this->castRows)-1];
42
+            return $this->castRows[count($this->castRows) - 1];
43 43
         }
44 44
     }
45 45
 
Please login to merge, or discard this patch.
src/Table.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      * @param int $numPeekRows
27 27
      * @return array of validation errors
28 28
      */
29
-    public static function validate($dataSource, $schema, $numPeekRows=10)
29
+    public static function validate($dataSource, $schema, $numPeekRows = 10)
30 30
     {
31 31
         try {
32 32
             $table = new static($dataSource, $schema);
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
                 // validation error in one of the fields
50 50
                 return array_map(function($validationError) use ($i) {
51 51
                     return new SchemaValidationError(SchemaValidationError::ROW_FIELD_VALIDATION, [
52
-                        "row" => $i+1,
52
+                        "row" => $i + 1,
53 53
                         "field" => $validationError->extraDetails["field"],
54 54
                         "error" => $validationError->extraDetails["error"],
55 55
                         "value" => $validationError->extraDetails["value"],
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 
74 74
     // not interesting, standard iterator functions
75 75
     // to simplify we prevent rewinding - so you can only iterate once
76
-    public function __destruct() {$this->dataSource->close();}
77
-    public function rewind() {if ($this->currentLine == 0) {$this->currentLine = 1;} else {throw new \Exception("rewind is not supported");}}
78
-    public function key() {return $this->currentLine;}
79
-    public function next() {$this->currentLine++;}
80
-    public function valid() {return !$this->dataSource->isEof();}
76
+    public function __destruct() {$this->dataSource->close(); }
77
+    public function rewind() {if ($this->currentLine == 0) {$this->currentLine = 1; } else {throw new \Exception("rewind is not supported"); }}
78
+    public function key() {return $this->currentLine; }
79
+    public function next() {$this->currentLine++; }
80
+    public function valid() {return !$this->dataSource->isEof(); }
81 81
 
82 82
     protected $currentLine = 0;
83 83
     protected $dataSource;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,9 @@
 block discarded – undo
37 37
             $i = 0;
38 38
             try {
39 39
                 foreach ($table as $row) {
40
-                    if (++$i > $numPeekRows) break;
40
+                    if (++$i > $numPeekRows) {
41
+                        break;
42
+                    }
41 43
                 }
42 44
             } catch (Exceptions\DataSourceException $e) {
43 45
                 // general error in getting the next row from the data source
Please login to merge, or discard this patch.
src/Fields/FieldsFactory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         throw new FieldValidationException([
34 34
             new SchemaValidationError(
35 35
                 SchemaValidationError::SCHEMA_VIOLATION,
36
-                "Could not find a valid field for descriptor: ".json_encode($descriptor))
36
+                "Could not find a valid field for descriptor: " . json_encode($descriptor))
37 37
         ]);
38 38
     }
39 39
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      * @return mixed
44 44
      * @throws FieldValidationException
45 45
      */
46
-    public static function infer($val, $descriptor=null, $lenient=false)
46
+    public static function infer($val, $descriptor = null, $lenient = false)
47 47
     {
48 48
         foreach (static::$fieldClasses as $fieldClass) {
49 49
             /** @var BaseField $fieldClass */
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         throw new FieldValidationException([
55 55
             new SchemaValidationError(
56 56
                 SchemaValidationError::SCHEMA_VIOLATION,
57
-                "Could not find a valid field for value: ".json_encode($val))
57
+                "Could not find a valid field for value: " . json_encode($val))
58 58
         ]);
59 59
     }
60 60
 }
61 61
\ No newline at end of file
Please login to merge, or discard this patch.