Completed
Push — master ( 79bbce...abd19f )
by Antonio Carlos
07:57 queued 05:51
created
src/update/Helper.php 2 patches
Doc Comments   +18 added lines, -13 removed lines patch added patch discarded remove patch
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
     /**
70 70
      * Add suffix to string.
71 71
      *
72
-     * @param $suffix
73
-     * @param $string
74
-     * @return mixed
72
+     * @param string string
73
+     * @param string $string
74
+     * @return string
75 75
      */
76 76
     protected function addSuffix($suffix, $string)
77 77
     {
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     /**
99 99
      * Delete a whole directory.
100 100
      *
101
-     * @param $dir
101
+     * @param string $dir
102 102
      */
103 103
     protected function deleteDirectory($dir)
104 104
     {
@@ -116,6 +116,11 @@  discard block
 block discarded – undo
116 116
         rmdir($dir);
117 117
     }
118 118
 
119
+    /**
120
+     * @param string $string
121
+     *
122
+     * @return resource
123
+     */
119 124
     protected function fopenOrFail($url, $string)
120 125
     {
121 126
         if (($handle = @fopen($url, $string)) === false) {
@@ -184,7 +189,7 @@  discard block
 block discarded – undo
184 189
 
185 190
     /**
186 191
      * @param $url
187
-     * @param $destination
192
+     * @param string $destination
188 193
      */
189 194
     public function downloadFile($url, $destination)
190 195
     {
@@ -255,8 +260,8 @@  discard block
 block discarded – undo
255 260
     /**
256 261
      * @param $file
257 262
      * @param $subPath
258
-     * @param $path
259
-     * @param $exclude
263
+     * @param string $path
264
+     * @param string $exclude
260 265
      */
261 266
     protected function renameMasterToPackage($file, $subPath, $path, $exclude)
262 267
     {
@@ -310,8 +315,8 @@  discard block
 block discarded – undo
310 315
     /**
311 316
      * Load a shapeFile.
312 317
      *
313
-     * @param $dir
314
-     * @return \PragmaRX\Coollection\Package\Coollection
318
+     * @param string $dir
319
+     * @return string
315 320
      */
316 321
     public function shapeFile($dir)
317 322
     {
@@ -391,7 +396,7 @@  discard block
 block discarded – undo
391 396
      * Unzip a file.
392 397
      *
393 398
      * @param $file
394
-     * @param $path
399
+     * @param string $path
395 400
      */
396 401
     public function unzip($file, $path)
397 402
     {
@@ -483,7 +488,7 @@  discard block
 block discarded – undo
483 488
     /**
484 489
      * Load json files from dir.
485 490
      *
486
-     * @param $dir
491
+     * @param string $dir
487 492
      * @return \PragmaRX\Coollection\Package\Coollection
488 493
      */
489 494
     public function loadJsonFiles($dir)
@@ -569,7 +574,7 @@  discard block
 block discarded – undo
569 574
     /**
570 575
      * Loads a json file.
571 576
      *
572
-     * @param $file
577
+     * @param string $file
573 578
      * @param string $dir
574 579
      * @return \PragmaRX\Coollection\Package\Coollection
575 580
      * @throws \Exception
@@ -606,7 +611,7 @@  discard block
 block discarded – undo
606 611
     /**
607 612
      * Put contents into a file.
608 613
      *
609
-     * @param $file
614
+     * @param string $file
610 615
      * @param $contents
611 616
      */
612 617
     public function putFile($file, $contents)
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      */
159 159
     public function download($url, $directory)
160 160
     {
161
-        coollect((array) $url)->each(function ($url) use ($directory) {
161
+        coollect((array) $url)->each(function($url) use ($directory) {
162 162
             $filename = basename($url);
163 163
 
164 164
             $destination = $this->toDir("{$directory}/{$filename}");
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 
216 216
         $fw = $this->fopenOrFail($destination, 'w');
217 217
 
218
-        while (! feof($fr)) {
218
+        while (!feof($fr)) {
219 219
             fwrite($fw, fread($fr, 4096));
220 220
             flush();
221 221
         }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
         $ch = curl_init();
237 237
         curl_setopt($ch, CURLOPT_URL, $url);
238 238
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
239
-        curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function ($resource, $total, $downloaded) use (&$nextStep) {
239
+        curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($resource, $total, $downloaded) use (&$nextStep) {
240 240
             if ($downloaded > $nextStep) {
241 241
                 echo '.';
242 242
                 $nextStep += 8192;
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
     protected function renameMasterToPackage($file, $subPath, $path, $exclude)
262 262
     {
263 263
         if (ends_with($file, 'master.zip')) {
264
-            $dir = coollect(scandir($path))->filter(function ($file) use ($exclude) {
264
+            $dir = coollect(scandir($path))->filter(function($file) use ($exclude) {
265 265
                 return $file !== '.' && $file !== '..' && $file !== $exclude;
266 266
             })->first();
267 267
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
     {
278 278
         $path = dirname($file);
279 279
 
280
-        if (! ends_with($file, '.zip') || file_exists($subPath = "$path/$subPath")) {
280
+        if (!ends_with($file, '.zip') || file_exists($subPath = "$path/$subPath")) {
281 281
             return;
282 282
         }
283 283
 
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
      */
297 297
     public function delTree($dir)
298 298
     {
299
-        if (! file_exists($dir)) {
299
+        if (!file_exists($dir)) {
300 300
             return false;
301 301
         }
302 302
 
@@ -333,9 +333,9 @@  discard block
 block discarded – undo
333 333
 
334 334
         unset($shapeRecords);
335 335
 
336
-        return coollect($result)->mapWithKeys(function ($fields, $key1) {
336
+        return coollect($result)->mapWithKeys(function($fields, $key1) {
337 337
             return [
338
-                strtolower($key1) => coollect($fields)->mapWithKeys(function ($value, $key2) {
338
+                strtolower($key1) => coollect($fields)->mapWithKeys(function($value, $key2) {
339 339
                     return [strtolower($key2) => $value];
340 340
                 }),
341 341
             ];
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 
355 355
         $array = arrayable($array) ? $array->toArray() : $array;
356 356
 
357
-        array_walk($array, function ($value, $key) use (&$result) {
357
+        array_walk($array, function($value, $key) use (&$result) {
358 358
             $result[snake_case($key)] = arrayable($value) || is_array($value)
359 359
                 ? $this->arrayKeysSnakeRecursive($value)
360 360
                 : $value;
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      */
383 383
     public function fixUtf8($string)
384 384
     {
385
-        return preg_replace_callback('/\\\\u([0-9a-fA-F]{4})/', function ($match) {
385
+        return preg_replace_callback('/\\\\u([0-9a-fA-F]{4})/', function($match) {
386 386
             return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
387 387
         }, $string);
388 388
     }
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
      */
419 419
     public function downloadDataFiles()
420 420
     {
421
-        $this->config->get('downloadable')->each(function ($urls, $path) {
422
-            if (! file_exists($destination = $this->dataDir("third-party/$path"))) {
423
-                coollect($urls)->each(function ($url) use ($path, $destination) {
421
+        $this->config->get('downloadable')->each(function($urls, $path) {
422
+            if (!file_exists($destination = $this->dataDir("third-party/$path"))) {
423
+                coollect($urls)->each(function($url) use ($path, $destination) {
424 424
                     $this->download($url, $destination);
425 425
 
426 426
                     $file = basename($url);
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
      */
489 489
     public function loadJsonFiles($dir)
490 490
     {
491
-        return coollect(glob("$dir/*.json*"))->mapWithKeys(function ($file) {
491
+        return coollect(glob("$dir/*.json*"))->mapWithKeys(function($file) {
492 492
             $key = str_replace('.json', '', str_replace('.json5', '', basename($file)));
493 493
 
494 494
             return [$key => $this->loadJson($file)];
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
      */
522 522
     public function moveDataFiles()
523 523
     {
524
-        $this->config->get('moveable')->each(function ($to, $from) {
524
+        $this->config->get('moveable')->each(function($to, $from) {
525 525
             $this->moveDataFile($from, $to);
526 526
         });
527 527
     }
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
      */
551 551
     public function message($message, $type = 'line')
552 552
     {
553
-        if (! is_null($this->command)) {
553
+        if (!is_null($this->command)) {
554 554
             $this->command->{$type}($message);
555 555
         }
556 556
     }
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
             $this->abort('loadCsv Error: File name not set');
581 581
         }
582 582
 
583
-        if (! file_exists($file)) {
583
+        if (!file_exists($file)) {
584 584
             $file = $this->dataDir($this->addSuffix('.csv', "/$dir/".strtolower($file)));
585 585
         }
586 586
 
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
      */
597 597
     public function makeJsonFileName($key, $dir = '')
598 598
     {
599
-        if (! ends_with($dir, (DIRECTORY_SEPARATOR))) {
599
+        if (!ends_with($dir, (DIRECTORY_SEPARATOR))) {
600 600
             $dir .= DIRECTORY_SEPARATOR;
601 601
         }
602 602
 
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
     {
678 678
         $this->progress('--- Delete temporary files');
679 679
 
680
-        $this->config->get('deletable')->each(function ($directory) {
680
+        $this->config->get('deletable')->each(function($directory) {
681 681
             if (file_exists($directory = $this->dataDir($directory))) {
682 682
                 $this->deleteDirectory($directory);
683 683
             }
Please login to merge, or discard this patch.