Passed
Branch master (96122f)
by Chizhov
07:34
created
src/Records.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     $pos = 1;
53 53
     foreach ($this->columns as $column) {
54 54
       $sub_data = (in_array($column["type"], $this->notTrimTypes)) ? substr($data, $pos, $column["length"]) : trim(substr($data, $pos, $column["length"]));
55
-      switch($column["type"]) {
55
+      switch ($column["type"]) {
56 56
         case "F":
57 57
         case "N":
58 58
           $record[$column["name"]] = (is_numeric($sub_data)) ? (($column["decimal"]) ? (float) $sub_data : (int) $sub_data) : null;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
           $record[$column["name"]] = empty($sub_data) ? null : $sub_data;
72 72
           break;
73 73
         case "L":
74
-          $record[$column["name"]] =  ($sub_data == "?" || empty($sub_data)) ? null : (in_array(strtolower($sub_data), $this->logicals));
74
+          $record[$column["name"]] = ($sub_data == "?" || empty($sub_data)) ? null : (in_array(strtolower($sub_data), $this->logicals));
75 75
           break;
76 76
         case "C":
77 77
           $record[$column["name"]] = $this->convertChar($sub_data);
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         case "M":
80 80
         case "P":
81 81
         case "G":
82
-          $sub_data = (strlen($sub_data) == 4) ? unpack("L", $sub_data)[1] : (int)$sub_data;
82
+          $sub_data = (strlen($sub_data) == 4) ? unpack("L", $sub_data)[1] : (int) $sub_data;
83 83
           if (!$sub_data) {
84 84
             $record[$column["name"]] = "";
85 85
           } else {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
       $this->headers = $data->getHeaders();
24 24
       $this->columns = $data->getColumns();
25 25
       $this->fp = $data->getData();
26
-    }
27
-    else {
26
+    } else {
28 27
       if (is_null($headers) || is_null($columns)) {
29 28
         throw new \Exception('Not correct data in Record class');
30 29
       }
Please login to merge, or discard this patch.
src/Table.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -45,23 +45,23 @@  discard block
 block discarded – undo
45 45
 
46 46
   private $charsets = [
47 47
     0   => 866, //If charset not defined
48
-    1   => 437,    2   => 850,    3   => 1252,    4   => 10000,    8   => 865,
49
-    9   => 437,    10  => 850,    11  => 437,     13  => 437,      14  => 850,
50
-    15  => 437,    16  => 850,    17  => 437,     18  => 850,      19  => 932,
51
-    20  => 850,    21  => 850,    22  => 437,     23  => 850,      24  => 437,
52
-    25  => 437,    26  => 850,    27  => 437,     28  => 863,      29  => 850,
53
-    31  => 852,    34  => 852,    35  => 852,     36  => 860,      37  => 850,
54
-    38  => 866,    55  => 850,    64  => 852,     77  => 936,      78  => 949,
55
-    79  => 950,    80  => 874,    88  => 1252,    89  => 1252,     100 => 852,
56
-    101 => 866,    102 => 865,    103 => 861,     104 => 895,      105 => 866,
57
-    106 => 737,    107 => 857,    108 => 863,     120 => 950,      121 => 949,
58
-    122 => 936,    123 => 932,    124 => 874,     134 => 737,      135 => 852,
59
-    136 => 857,    150 => 10007,  151 => 10029,   152 => 10006,    200 => 1250,
60
-    201 => 1251,   202 => 1254,   203 => 1253,    204 => 1257
48
+    1   => 437, 2   => 850, 3   => 1252, 4   => 10000, 8   => 865,
49
+    9   => 437, 10  => 850, 11  => 437, 13  => 437, 14  => 850,
50
+    15  => 437, 16  => 850, 17  => 437, 18  => 850, 19  => 932,
51
+    20  => 850, 21  => 850, 22  => 437, 23  => 850, 24  => 437,
52
+    25  => 437, 26  => 850, 27  => 437, 28  => 863, 29  => 850,
53
+    31  => 852, 34  => 852, 35  => 852, 36  => 860, 37  => 850,
54
+    38  => 866, 55  => 850, 64  => 852, 77  => 936, 78  => 949,
55
+    79  => 950, 80  => 874, 88  => 1252, 89  => 1252, 100 => 852,
56
+    101 => 866, 102 => 865, 103 => 861, 104 => 895, 105 => 866,
57
+    106 => 737, 107 => 857, 108 => 863, 120 => 950, 121 => 949,
58
+    122 => 936, 123 => 932, 124 => 874, 134 => 737, 135 => 852,
59
+    136 => 857, 150 => 10007, 151 => 10029, 152 => 10006, 200 => 1250,
60
+    201 => 1251, 202 => 1254, 203 => 1253, 204 => 1257
61 61
   ];
62 62
   private $dbase7 = false, $v_foxpro = false;
63 63
 
64
-  public function __construct($dbPath, $charset = null){
64
+  public function __construct($dbPath, $charset = null) {
65 65
     $this->db = $dbPath;
66 66
     if (!is_null($charset)) {
67 67
       if (!is_numeric($charset)) {
@@ -233,16 +233,16 @@  discard block
 block discarded – undo
233 233
 
234 234
   private function fileExists($fileName) {
235 235
 
236
-    if(file_exists($fileName)) {
236
+    if (file_exists($fileName)) {
237 237
       return $fileName;
238 238
     }
239 239
 
240 240
     // Handle case insensitive requests
241 241
     $directoryName = dirname($fileName);
242
-    $fileArray = glob($directoryName . '/*', GLOB_NOSORT);
242
+    $fileArray = glob($directoryName.'/*', GLOB_NOSORT);
243 243
     $fileNameLowerCase = strtolower($fileName);
244
-    foreach($fileArray as $file) {
245
-      if(strtolower($file) == $fileNameLowerCase) {
244
+    foreach ($fileArray as $file) {
245
+      if (strtolower($file) == $fileNameLowerCase) {
246 246
         return $file;
247 247
       }
248 248
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -132,20 +132,17 @@  discard block
 block discarded – undo
132 132
     if ($this->headers["checks"][0] != 0) {
133 133
       $this->error = true;
134 134
       $this->error_info = "Not correct DBF file by headers";
135
-    }
136
-    else {
135
+    } else {
137 136
       $this->headers["charset_name"] = "cp".$this->charsets[$this->headers["charset"]];
138 137
 
139 138
       if (in_array("dBASE 7", $this->versions[$this->headers["version"]])) {
140 139
         $this->dbase7 = true;
141 140
         $this->headers["columns"] = ($this->headers["header_length"] - 68) / 48;
142
-      }
143
-      elseif (in_array("Visual FoxPro", $this->versions[$this->headers["version"]])) {
141
+      } elseif (in_array("Visual FoxPro", $this->versions[$this->headers["version"]])) {
144 142
         $this->v_foxpro = true;
145 143
         $this->headers["memo"] = (in_array($this->headers["mdx_flag"], [2, 3, 6, 7]));
146 144
         $this->headers["columns"] = ($this->headers["header_length"] - 296) / 32;
147
-      }
148
-      else {
145
+      } else {
149 146
         $this->headers["columns"] = ($this->headers["header_length"] - 33) / 32;
150 147
       }
151 148
 
@@ -178,8 +175,7 @@  discard block
 block discarded – undo
178 175
             "mdx_flag" => unpack("C", $data[37])[1],
179 176
             "auto_increment" => unpack("L", substr($data, 40, 4))[1]
180 177
           ];
181
-        }
182
-        else {
178
+        } else {
183 179
           $this->columns[$i] = [
184 180
             "name" => strtolower(trim(substr($data, 0, 11))),
185 181
             "type" => $data[11],
@@ -196,8 +192,7 @@  discard block
 block discarded – undo
196 192
               $this->columns[$i]["auto_increment_next"] = unpack("L", substr($data, 19, 4))[1];
197 193
               $this->columns[$i]["auto_increment_step"] = unpack("C", $data[23])[1];
198 194
             }
199
-          }
200
-          else {
195
+          } else {
201 196
             $this->columns[$i]["mdx_flag"] = unpack("C", $data[31])[1];
202 197
           }
203 198
         }
Please login to merge, or discard this patch.