Passed
Branch master (506a2b)
by Alexander
04:15
created
src/RandomToFile.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
                 if (count($keys)) {
111 111
                     //nested array ended
112 112
                     $out_str = "/* end $out_str"
113
-                              .'['. \implode('][', $keys) . ']'
114
-                              . "*/\r\n";
113
+                                .'['. \implode('][', $keys) . ']'
114
+                                . "*/\r\n";
115 115
                     \array_pop($keys);
116 116
                 } else {
117 117
                     //root array ended
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
         }
219 219
 
220 220
         $signal = 'close';
221
-         \call_user_func($this->fn_file_output,
221
+            \call_user_func($this->fn_file_output,
222 222
             \compact('signal', 'fh', 'elem_cnt', 'lim_depth', 'root')
223
-         );
223
+            );
224 224
 
225 225
         if (! $oh) {
226 226
             $this->closeOutputFile();
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -254,7 +254,9 @@
 block discarded – undo
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)) {
258
+                $ext = $this->default_ext;
259
+            }
258 260
             $file_name = $this->genTempFileName($ext);
259 261
         }
260 262
         return $this->full_file_name = $file_name;
Please login to merge, or discard this patch.
src/RandomArray.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -36,15 +36,15 @@
 block discarded – undo
36 36
      */
37 37
     public $lim_elements = 10000;
38 38
     
39
-     /**
40
-     * Model number for generation random Keys for Arrays
41
-     * if 0 then array keys will be simple 1,2,3... numeric
42
-     * if 1 then array keys will be numeric from min_arr_key to max_arr_key
43
-     * if 2 then array keys will be string len from min_arr_key to max_arr_key
44
-     * This value setting by function setKeysModel()
45
-     *
46
-     * @var integer
47
-     */
39
+        /**
40
+         * Model number for generation random Keys for Arrays
41
+         * if 0 then array keys will be simple 1,2,3... numeric
42
+         * if 1 then array keys will be numeric from min_arr_key to max_arr_key
43
+         * if 2 then array keys will be string len from min_arr_key to max_arr_key
44
+         * This value setting by function setKeysModel()
45
+         *
46
+         * @var integer
47
+         */
48 48
     protected $keys_model;
49 49
 
50 50
     /**
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      */
141 141
     public function countArrayValuesRecursive(&$arr, $cnt = 0)
142 142
     {
143
-        \array_walk_recursive($arr, function ($v, $k) use (&$cnt) {
143
+        \array_walk_recursive($arr, function($v, $k) use (&$cnt) {
144 144
             $cnt++;
145 145
         });
146 146
         return $cnt;
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
             return false;
161 161
         }
162 162
         $m_depth = $c_depth;
163
-        \array_walk($arr, function ($v, $k) use ($c_depth, &$m_depth) {
163
+        \array_walk($arr, function($v, $k) use ($c_depth, &$m_depth) {
164 164
             if (is_array($v)) {
165
-                $new_depth = $this->countArrayMaxDepth($v, $c_depth+1);
165
+                $new_depth = $this->countArrayMaxDepth($v, $c_depth + 1);
166 166
                 if ($new_depth > $m_depth) {
167 167
                     $m_depth = $new_depth;
168 168
                 }
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
         if (empty($chars)) {
224 224
             //Numeric values model
225 225
             $this->values_model = 1;
226
-            if (!$min && $max==65535) {
226
+            if (!$min && $max == 65535) {
227 227
                 //Non-changes values model (random number from 0 to 65535)
228
-                $this->values_model=0;
228
+                $this->values_model = 0;
229 229
             }
230 230
         } else {
231 231
             //Random-string values model
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
         if ($lim_elements) {
297 297
             $this->lim_elements = $lim_elements;
298 298
         }
299
-        if ($lim_depth<1
299
+        if ($lim_depth < 1
300 300
             || $this->lim_elements < 0
301 301
             || $this->max_arr_key < 0
302 302
             || $this->max_arr_key < $this->min_arr_key
@@ -311,11 +311,11 @@  discard block
 block discarded – undo
311 311
             $elem_cnt = $this->lim_elements;
312 312
         }
313 313
         $r_arr = [];
314
-        $gen_arr = \unpack('v*', \call_user_func($this->rnd_fn, $elem_cnt*2));
315
-        $this->lim_elements-=$elem_cnt;
314
+        $gen_arr = \unpack('v*', \call_user_func($this->rnd_fn, $elem_cnt * 2));
315
+        $this->lim_elements -= $elem_cnt;
316 316
         
317 317
         foreach ($gen_arr as $k => $v) {
318
-            if ($v > $threshold || $lim_depth<2 || $this->lim_elements <2) {
318
+            if ($v > $threshold || $lim_depth < 2 || $this->lim_elements < 2) {
319 319
                 if ($this->values_model) {
320 320
                     if ($this->values_model == 3) {
321 321
                         $v = \call_user_func($this->fn_gen_value,
Please login to merge, or discard this patch.
src/RandomStr.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
         } else {
95 95
             //by default used this characters
96 96
             $this->char_sets = [
97
-                'abcdefghijklmnopqrstuvwxyz'.
98
-                'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
97
+                'abcdefghijklmnopqrstuvwxyz' .
98
+                'ABCDEFGHIJKLMNOPQRSTUVWXYZ' .
99 99
                 '01234567890_-.'
100 100
                 ];
101 101
         }
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
             if ($len == \strlen($chars)) {
115 115
                 continue;
116 116
             }
117
-            $arr=[];
117
+            $arr = [];
118 118
             for ($i = 0; $i < $len; $i++) {
119 119
                 $arr[] = \mb_substr($chars, $i, 1, "UTF-8");
120 120
             }
121
-            $this->char_sets[$k]=$arr;
121
+            $this->char_sets[$k] = $arr;
122 122
         }
123 123
     }
124 124
     
@@ -140,14 +140,14 @@  discard block
 block discarded – undo
140 140
      */
141 141
     public function genRandomStr($len = 10, $char_set_num = 0)
142 142
     {
143
-        if (!isset($this->char_sets[$char_set_num]) || $len<1) {
143
+        if (!isset($this->char_sets[$char_set_num]) || $len < 1) {
144 144
             return false;
145 145
         } elseif (is_array($this->char_sets[$char_set_num])) {
146 146
             $l = count($this->char_sets[$char_set_num]);
147 147
         } else {
148 148
             $l = \strlen($this->char_sets[$char_set_num]);
149 149
         }
150
-        if (! $l) {
150
+        if (!$l) {
151 151
             return false;
152 152
         }
153 153
         $outstr = '';
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
      */
179 179
     public function md5RandomBytes($len)
180 180
     {
181
-        if($len>0) {
181
+        if ($len > 0) {
182 182
             $start = mt_rand(9, PHP_INT_MAX);
183 183
             $output = '';
184
-            for ($i=$start; strlen($output) < $len; $i++) {
184
+            for ($i = $start; strlen($output) < $len; $i++) {
185 185
                 $output .= md5($i, true);
186 186
             }
187 187
             return substr($output, 0, $len);
Please login to merge, or discard this patch.