@@ -52,7 +52,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 { |
@@ -28,8 +28,7 @@ |
||
| 28 | 28 | $this->headers = $data->getHeaders(); |
| 29 | 29 | $this->columns = $data->getColumns(); |
| 30 | 30 | $this->fp = $data->getData(); |
| 31 | - } |
|
| 32 | - else { |
|
| 31 | + } else { |
|
| 33 | 32 | if (is_null($headers) || is_null($columns)) { |
| 34 | 33 | throw new Exception('Not correct data in Record class'); |
| 35 | 34 | } |
@@ -47,26 +47,26 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | private $charsets = [ |
| 49 | 49 | 0 => 866, //If charset not defined |
| 50 | - 1 => 437, 2 => 850, 3 => 1252, 4 => 10000, 8 => 865, |
|
| 51 | - 9 => 437, 10 => 850, 11 => 437, 13 => 437, 14 => 850, |
|
| 52 | - 15 => 437, 16 => 850, 17 => 437, 18 => 850, 19 => 932, |
|
| 53 | - 20 => 850, 21 => 850, 22 => 437, 23 => 850, 24 => 437, |
|
| 54 | - 25 => 437, 26 => 850, 27 => 437, 28 => 863, 29 => 850, |
|
| 55 | - 31 => 852, 34 => 852, 35 => 852, 36 => 860, 37 => 850, |
|
| 56 | - 38 => 866, 55 => 850, 64 => 852, 77 => 936, 78 => 949, |
|
| 57 | - 79 => 950, 80 => 874, 88 => 1252, 89 => 1252, 100 => 852, |
|
| 58 | - 101 => 866, 102 => 865, 103 => 861, 104 => 895, 105 => 866, |
|
| 59 | - 106 => 737, 107 => 857, 108 => 863, 120 => 950, 121 => 949, |
|
| 60 | - 122 => 936, 123 => 932, 124 => 874, 134 => 737, 135 => 852, |
|
| 61 | - 136 => 857, 150 => 10007, 151 => 10029, 152 => 10006, 200 => 1250, |
|
| 62 | - 201 => 1251, 202 => 1254, 203 => 1253, 204 => 1257 |
|
| 50 | + 1 => 437, 2 => 850, 3 => 1252, 4 => 10000, 8 => 865, |
|
| 51 | + 9 => 437, 10 => 850, 11 => 437, 13 => 437, 14 => 850, |
|
| 52 | + 15 => 437, 16 => 850, 17 => 437, 18 => 850, 19 => 932, |
|
| 53 | + 20 => 850, 21 => 850, 22 => 437, 23 => 850, 24 => 437, |
|
| 54 | + 25 => 437, 26 => 850, 27 => 437, 28 => 863, 29 => 850, |
|
| 55 | + 31 => 852, 34 => 852, 35 => 852, 36 => 860, 37 => 850, |
|
| 56 | + 38 => 866, 55 => 850, 64 => 852, 77 => 936, 78 => 949, |
|
| 57 | + 79 => 950, 80 => 874, 88 => 1252, 89 => 1252, 100 => 852, |
|
| 58 | + 101 => 866, 102 => 865, 103 => 861, 104 => 895, 105 => 866, |
|
| 59 | + 106 => 737, 107 => 857, 108 => 863, 120 => 950, 121 => 949, |
|
| 60 | + 122 => 936, 123 => 932, 124 => 874, 134 => 737, 135 => 852, |
|
| 61 | + 136 => 857, 150 => 10007, 151 => 10029, 152 => 10006, 200 => 1250, |
|
| 62 | + 201 => 1251, 202 => 1254, 203 => 1253, 204 => 1257 |
|
| 63 | 63 | ]; |
| 64 | 64 | private $dbase7 = false, $v_foxpro = false; |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * @throws Exception |
| 68 | 68 | */ |
| 69 | - public function __construct($dbPath, $charset = null){ |
|
| 69 | + public function __construct($dbPath, $charset = null) { |
|
| 70 | 70 | $this->db = $dbPath; |
| 71 | 71 | if (!is_null($charset)) { |
| 72 | 72 | if (!is_numeric($charset)) { |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $this->error_info = "Not correct DBF file by headers"; |
| 143 | 143 | return; |
| 144 | 144 | } |
| 145 | - $this->headers["charset_name"] = "cp" . $this->charsets[$this->headers["charset"]]; |
|
| 145 | + $this->headers["charset_name"] = "cp".$this->charsets[$this->headers["charset"]]; |
|
| 146 | 146 | |
| 147 | 147 | if (in_array("dBASE 7", $this->versions[$this->headers["version"]])) { |
| 148 | 148 | $this->dbase7 = true; |
@@ -159,11 +159,11 @@ discard block |
||
| 159 | 159 | $this->headers["memo"] = in_array($this->headers["version"], $this->memo["versions"]); |
| 160 | 160 | } |
| 161 | 161 | if ($this->headers["memo"]) { |
| 162 | - $this->headers["memo_file"] = ($mfile = $this->getMemoFile($file["dirname"] . "/" . $file["filename"])) ? $mfile : null; |
|
| 162 | + $this->headers["memo_file"] = ($mfile = $this->getMemoFile($file["dirname"]."/".$file["filename"])) ? $mfile : null; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | $this->headers["version_name"] = |
| 166 | - implode(", ", $this->versions[$this->headers["version"]]) . " " . ($this->headers["memo"] ? "with" : "without") . " memo-fields"; |
|
| 166 | + implode(", ", $this->versions[$this->headers["version"]])." ".($this->headers["memo"] ? "with" : "without")." memo-fields"; |
|
| 167 | 167 | unset($this->headers["checks"], $this->headers["header_length"]); |
| 168 | 168 | } |
| 169 | 169 | |
@@ -243,10 +243,10 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | // Handle case-insensitive requests |
| 245 | 245 | $directoryName = dirname($fileName); |
| 246 | - $fileArray = glob($directoryName . '/*', GLOB_NOSORT); |
|
| 246 | + $fileArray = glob($directoryName.'/*', GLOB_NOSORT); |
|
| 247 | 247 | $fileNameLowerCase = strtolower($fileName); |
| 248 | - foreach($fileArray as $file) { |
|
| 249 | - if(strtolower($file) == $fileNameLowerCase) { |
|
| 248 | + foreach ($fileArray as $file) { |
|
| 249 | + if (strtolower($file) == $fileNameLowerCase) { |
|
| 250 | 250 | return $file; |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -183,8 +183,7 @@ discard block |
||
| 183 | 183 | "mdx_flag" => unpack("C", $data[37])[1], |
| 184 | 184 | "auto_increment" => unpack("L", substr($data, 40, 4))[1] |
| 185 | 185 | ]; |
| 186 | - } |
|
| 187 | - else { |
|
| 186 | + } else { |
|
| 188 | 187 | $this->columns[$i] = [ |
| 189 | 188 | "name" => strtolower(trim(substr($data, 0, 11))), |
| 190 | 189 | "type" => $data[11], |
@@ -202,8 +201,7 @@ discard block |
||
| 202 | 201 | $this->columns[$i]["auto_increment_next"] = unpack("L", substr($data, 19, 4))[1]; |
| 203 | 202 | $this->columns[$i]["auto_increment_step"] = unpack("C", $data[23])[1]; |
| 204 | 203 | } |
| 205 | - } |
|
| 206 | - else { |
|
| 204 | + } else { |
|
| 207 | 205 | $this->columns[$i]["mdx_flag"] = unpack("C", $data[31])[1]; |
| 208 | 206 | } |
| 209 | 207 | } |