@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | protected function writeFileOutputExample($parr) |
65 | 65 | { |
66 | - static $keys=[]; |
|
66 | + static $keys = []; |
|
67 | 67 | |
68 | 68 | //extracting following work variables: |
69 | 69 | \extract($parr); //$signal, $k, $v, $lim_depth, $root |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | $v = "'" . \addcslashes($v, "'\\") . "'"; |
82 | 82 | } |
83 | 83 | $out_str .= (count($keys) ? |
84 | - '[' . implode('][', $keys) .']' |
|
84 | + '[' . implode('][', $keys) . ']' |
|
85 | 85 | : |
86 | 86 | '' |
87 | - ) . '['.$k.']=' . $v . ";\r\n"; |
|
87 | + ) . '[' . $k . ']=' . $v . ";\r\n"; |
|
88 | 88 | |
89 | 89 | break; |
90 | 90 | |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | $out_str .= "=[]; /* Create sub-array in key $out_str */\r\n"; |
101 | 101 | } else { |
102 | 102 | //root array beginned |
103 | - $out_str .="=[]; /* CREATE ROOT OF ARRAY */\r\n"; |
|
104 | - $out_str = '<'."?php\n" . $out_str; |
|
103 | + $out_str .= "=[]; /* CREATE ROOT OF ARRAY */\r\n"; |
|
104 | + $out_str = '<' . "?php\n" . $out_str; |
|
105 | 105 | } |
106 | 106 | break; |
107 | 107 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | if (count($keys)) { |
111 | 111 | //nested array ended |
112 | 112 | $out_str = "/* end $out_str" |
113 | - .'['. \implode('][', $keys) . ']' |
|
113 | + .'[' . \implode('][', $keys) . ']' |
|
114 | 114 | . "*/\r\n"; |
115 | 115 | \array_pop($keys); |
116 | 116 | } else { |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | //signal 'init' - when file open for write |
123 | 123 | case 'init': |
124 | - $keys=[]; |
|
124 | + $keys = []; |
|
125 | 125 | $out_str = ''; |
126 | 126 | } |
127 | 127 | //write formed string to output file |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | if ($lim_elements) { |
140 | 140 | $this->lim_elements = $lim_elements; |
141 | 141 | } |
142 | - if ($lim_depth<1 |
|
142 | + if ($lim_depth < 1 |
|
143 | 143 | || $this->lim_elements < 0 |
144 | 144 | || $this->max_arr_key < 0 |
145 | 145 | || $this->max_arr_key < $this->min_arr_key |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | return false; |
150 | 150 | } |
151 | 151 | |
152 | - if (! $oh = $fh = $this->file_handler) { |
|
152 | + if (!$oh = $fh = $this->file_handler) { |
|
153 | 153 | $this->openOutputFile(); |
154 | 154 | $fh = $this->file_handler; |
155 | 155 | $signal = 'init'; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $elem_cnt = $this->lim_elements; |
164 | 164 | } |
165 | 165 | |
166 | - $this->lim_elements-=$elem_cnt; |
|
166 | + $this->lim_elements -= $elem_cnt; |
|
167 | 167 | |
168 | 168 | $signal = 'open'; |
169 | 169 | \call_user_func($this->fn_file_output, |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | - if ($v > $threshold || $lim_depth<2 || $this->lim_elements <2) { |
|
190 | + if ($v > $threshold || $lim_depth < 2 || $this->lim_elements < 2) { |
|
191 | 191 | if ($this->values_model) { |
192 | 192 | if ($this->values_model == 3) { |
193 | 193 | $v = \call_user_func($this->fn_gen_value, |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | \compact('signal', 'fh', 'elem_cnt', 'lim_depth', 'root') |
223 | 223 | ); |
224 | 224 | |
225 | - if (! $oh) { |
|
225 | + if (!$oh) { |
|
226 | 226 | $this->closeOutputFile(); |
227 | 227 | } |
228 | 228 | return true; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | protected function genBigRange($total_elements) |
232 | 232 | { |
233 | - for ($k=1; $k<=$total_elements; $k++) { |
|
233 | + for ($k = 1; $k <= $total_elements; $k++) { |
|
234 | 234 | $v = \mt_rand(0, 65535); |
235 | 235 | yield $k => $v; |
236 | 236 | } |
@@ -247,14 +247,14 @@ discard block |
||
247 | 247 | if (is_null($ext)) { |
248 | 248 | $ext = $this->default_ext; |
249 | 249 | } |
250 | - $file_name.= DIRECTORY_SEPARATOR . md5(microtime()) . $ext; |
|
250 | + $file_name .= DIRECTORY_SEPARATOR . md5(microtime()) . $ext; |
|
251 | 251 | return $file_name; |
252 | 252 | } |
253 | 253 | |
254 | 254 | public function setOutputFile($file_name = null, $ext = null) |
255 | 255 | { |
256 | 256 | if (empty($file_name) || !is_string($file_name)) { |
257 | - if(!is_null($ext)) $ext = $this->default_ext; |
|
257 | + if (!is_null($ext)) $ext = $this->default_ext; |
|
258 | 258 | $file_name = $this->genTempFileName($ext); |
259 | 259 | } |
260 | 260 | return $this->full_file_name = $file_name; |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | |
263 | 263 | protected function openOutputFile() |
264 | 264 | { |
265 | - if (! $this->file_handler = \fopen($this->full_file_name, 'w')) { |
|
266 | - throw new \Exception("Error write file ".$this->jsonFileName); |
|
265 | + if (!$this->file_handler = \fopen($this->full_file_name, 'w')) { |
|
266 | + throw new \Exception("Error write file " . $this->jsonFileName); |
|
267 | 267 | } |
268 | 268 | return $this->file_handler; |
269 | 269 | } |