Completed
Push — master ( 61832e...fba729 )
by Antonio Carlos
06:18
created
src/package/Support/Collection.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      */
100 100
     private function arrayFinder(string $propertyName, $find, Closure $finderClosure)
101 101
     {
102
-        return $this->filter(function ($data) use ($find, $propertyName, $finderClosure) {
102
+        return $this->filter(function($data) use ($find, $propertyName, $finderClosure) {
103 103
             try {
104 104
                 $attributeValue = $data->{$propertyName};
105 105
             } catch (\Exception $e) {
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      */
122 122
     private function _whereKey(string $arrayName, $value)
123 123
     {
124
-        $finderClosure = function ($value, $attributeValue) {
124
+        $finderClosure = function($value, $attributeValue) {
125 125
             return Arr::has($attributeValue, $value);
126 126
         };
127 127
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      */
138 138
     private function _whereAttribute(string $arrayName, $value)
139 139
     {
140
-        $finderClosure = function ($value, $attributeValue) {
140
+        $finderClosure = function($value, $attributeValue) {
141 141
             return in_array($value, $attributeValue->toArray());
142 142
         };
143 143
 
Please login to merge, or discard this patch.
src/package/Support/helpers.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 use PragmaRX\Countries\Package\Support\Collection;
4 4
 
5
-if (! function_exists('array_sort_by_keys_recursive')) {
5
+if (!function_exists('array_sort_by_keys_recursive')) {
6 6
     /**
7 7
      * Recursively sort array by keys.
8 8
      *
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     }
22 22
 }
23 23
 
24
-if (! function_exists('countriesCollect')) {
24
+if (!function_exists('countriesCollect')) {
25 25
     /**
26 26
      * Check if array is multidimensional.
27 27
      *
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     }
35 35
 }
36 36
 
37
-if (! function_exists('arrayable')) {
37
+if (!function_exists('arrayable')) {
38 38
     /**
39 39
      * Recursively change all array keys case.
40 40
      *
Please login to merge, or discard this patch.
src/update/Rinvex.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             'latlng'       => 'geo',
62 62
         ];
63 63
 
64
-        coollect($mergeable)->each(function ($to, $key) use (&$natural) {
64
+        coollect($mergeable)->each(function($to, $key) use (&$natural) {
65 65
             if (isset($natural[$key])) {
66 66
                 $natural->overwrite([$to => [$key => $natural[$key]]]);
67 67
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function findRinvexState($country, $needle)
115 115
     {
116
-        $states = $this->findRinvex($country, 'divisions')->map(function ($state, $postal) {
116
+        $states = $this->findRinvex($country, 'divisions')->map(function($state, $postal) {
117 117
             $state['postal'] = $postal;
118 118
 
119 119
             $state['name'] = $this->helper->fixUtf8($state['name']);
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
             return $states;
126 126
         }
127 127
 
128
-        $state = $states->filter(function ($rinvexState) use ($needle) {
128
+        $state = $states->filter(function($rinvexState) use ($needle) {
129 129
             return $rinvexState->postal == $needle->postal ||
130 130
                 $rinvexState->name == $needle['name'] ||
131 131
                 utf8_encode($rinvexState->name) == $needle['name'] ||
132 132
                 $rinvexState->alt_names->contains($needle['name']) ||
133
-                $rinvexState->alt_names->contains(function ($name) use ($needle) {
133
+                $rinvexState->alt_names->contains(function($name) use ($needle) {
134 134
                     return $needle->alt_names->contains($name);
135 135
                 });
136 136
         })->first();
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
                 continue;
205 205
             }
206 206
 
207
-            if ($rinvexValue !== $naturalValue && ! $defaultToRinvex->contains($key)) {
207
+            if ($rinvexValue !== $naturalValue && !$defaultToRinvex->contains($key)) {
208 208
                 $result[$key.$suffix] = $rinvexValue; // Natural Earth Vector
209 209
             }
210 210
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
                 : $naturalValue; // Natural Earth Vector
214 214
         }
215 215
 
216
-        return coollect($result)->sortBy(function ($value, $key) {
216
+        return coollect($result)->sortBy(function($value, $key) {
217 217
             return $key;
218 218
         });
219 219
     }
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
      */
227 227
     public function mergeCountryStatesWithRinvex($states)
228 228
     {
229
-        return coollect($states)->map(function ($state) {
229
+        return coollect($states)->map(function($state) {
230 230
             return $this->mergeStateWithRinvex($state);
231 231
         });
232 232
     }
Please login to merge, or discard this patch.
src/update/States.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
         $this->helper->message('Processing states...');
53 53
 
54
-        $normalizerClosure = function ($item) {
54
+        $normalizerClosure = function($item) {
55 55
             $item = $this->updater->addDataSource($item, 'natural');
56 56
 
57 57
             $item = $this->updater->addRecordType($item, 'state');
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
             return $this->updater->normalizeStateOrCityData($item);
60 60
         };
61 61
 
62
-        $getCodeClosure = function ($item) {
62
+        $getCodeClosure = function($item) {
63 63
             return $this->makeStatePostalCode($item);
64 64
         };
65 65
 
66
-        $mergerClosure = function ($states) {
66
+        $mergerClosure = function($states) {
67 67
             return $this->rinvex->mergeCountryStatesWithRinvex($states);
68 68
         };
69 69
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
             }
91 91
         }
92 92
 
93
-        if (! empty(trim($item->postal))) {
93
+        if (!empty(trim($item->postal))) {
94 94
             $item->postal;
95 95
         }
96 96
 
Please login to merge, or discard this patch.
src/update/Countries.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
         $dataDir = '/countries/default/';
74 74
 
75
-        $this->updater->setCountries($this->cache->remember('updateCountries->buildCountriesCoollection', 160, function () use ($dataDir) {
75
+        $this->updater->setCountries($this->cache->remember('updateCountries->buildCountriesCoollection', 160, function() use ($dataDir) {
76 76
             $this->helper->eraseDataDir($dataDir);
77 77
 
78 78
             return $this->buildCountriesCoollection($dataDir);
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
 
101 101
         $mledoze = $this->mledoze->loadMledozeCountries();
102 102
 
103
-        $countries = coollect($this->helper->loadShapeFile('third-party/natural_earth/ne_10m_admin_0_countries'))->map(function ($country) {
103
+        $countries = coollect($this->helper->loadShapeFile('third-party/natural_earth/ne_10m_admin_0_countries'))->map(function($country) {
104 104
             return $this->natural->fixNaturalOddCountries($country);
105
-        })->mapWithKeys(function ($natural) use ($mledoze, $dataDir) {
105
+        })->mapWithKeys(function($natural) use ($mledoze, $dataDir) {
106 106
             list($mledoze, $countryCode) = $this->mledoze->findMledozeCountry($mledoze, $natural);
107 107
 
108
-            $natural = coollect($natural)->mapWithKeys(function ($country, $key) {
108
+            $natural = coollect($natural)->mapWithKeys(function($country, $key) {
109 109
                 return [strtolower($key) => $country];
110 110
             });
111 111
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
     public function clearCountryCurrencies($country)
145 145
     {
146
-        if (isset($country['currency']) && ! is_null($country['currency'])) {
146
+        if (isset($country['currency']) && !is_null($country['currency'])) {
147 147
             $country['currencies'] = array_keys($country['currency']);
148 148
 
149 149
             unset($country['currency']);
Please login to merge, or discard this patch.
src/update/Mledoze.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      */
45 45
     public function loadMledozeCountries()
46 46
     {
47
-        $mledoze = coollect($this->helper->loadJson('countries', 'third-party/mledoze/dist'))->mapWithKeys(function (
47
+        $mledoze = coollect($this->helper->loadJson('countries', 'third-party/mledoze/dist'))->mapWithKeys(function(
48 48
             $country
49 49
         ) {
50 50
             $country = $this->updater->addDataSource($country, 'mledoze');
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     {
99 99
         list($country, $countryCode) = $this->updater->findCountryByAnyField($mledoze, $natural);
100 100
 
101
-        if (! $country->isEmpty()) {
101
+        if (!$country->isEmpty()) {
102 102
             return [coollect($this->helper->arrayKeysSnakeRecursive($country)), $countryCode];
103 103
         }
104 104
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
             $result[$key] = $mledozeValue; // Natural Earth Vector
147 147
         }
148 148
 
149
-        return coollect($result)->sortBy(function ($value, $key) {
149
+        return coollect($result)->sortBy(function($value, $key) {
150 150
             return $key;
151 151
         });
152 152
     }
Please login to merge, or discard this patch.
src/update/Cities.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
         $this->helper->message('Processing cities...');
45 45
 
46
-        $normalizerClosure = function ($item) {
46
+        $normalizerClosure = function($item) {
47 47
             $item = $this->updater->addDataSource($item, 'natural');
48 48
 
49 49
             $item = $this->updater->addRecordType($item, 'city');
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
             return $this->updater->normalizeStateOrCityData($item);
52 52
         };
53 53
 
54
-        $codeGeneratorClosure = function ($item) {
54
+        $codeGeneratorClosure = function($item) {
55 55
             return $this->helper->caseForKey($item['nameascii']);
56 56
         };
57 57
 
58
-        $mergerClosure = function ($item) {
58
+        $mergerClosure = function($item) {
59 59
             return $item;
60 60
         };
61 61
 
Please login to merge, or discard this patch.
src/update/Currencies.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
             throw new Exception("No currencies found in {$directory}");
48 48
         }
49 49
 
50
-        $currencies = $currencies->mapWithKeys(function ($currency) {
50
+        $currencies = $currencies->mapWithKeys(function($currency) {
51 51
             return $currency;
52 52
         });
53 53
 
54 54
         $this->helper->message('Processing currencies...');
55 55
 
56
-        $normalizerClosure = function ($item) {
56
+        $normalizerClosure = function($item) {
57 57
             $item = $this->updater->addDataSource($item, 'world-currencies');
58 58
 
59 59
             $item = $this->updater->addRecordType($item, 'currency');
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
             return [$item];
62 62
         };
63 63
 
64
-        $getCodeClosure = function () {
64
+        $getCodeClosure = function() {
65 65
         };
66 66
 
67
-        $generateTaxData = function ($tax) {
67
+        $generateTaxData = function($tax) {
68 68
             return $tax;
69 69
         };
70 70
 
Please login to merge, or discard this patch.
src/update/Helper.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      */
160 160
     public function download($url, $directory)
161 161
     {
162
-        coollect((array) $url)->each(function ($url) use ($directory) {
162
+        coollect((array) $url)->each(function($url) use ($directory) {
163 163
             $filename = basename($url);
164 164
 
165 165
             $destination = $this->toDir("{$directory}/{$filename}");
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 
217 217
         $fw = $this->fopenOrFail($destination, 'w');
218 218
 
219
-        while (! feof($fr)) {
219
+        while (!feof($fr)) {
220 220
             fwrite($fw, fread($fr, 4096));
221 221
             flush();
222 222
         }
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
         $ch = curl_init();
238 238
         curl_setopt($ch, CURLOPT_URL, $url);
239 239
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
240
-        curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function ($resource, $total, $downloaded) use (&$nextStep) {
240
+        curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($resource, $total, $downloaded) use (&$nextStep) {
241 241
             if ($downloaded > $nextStep) {
242 242
                 echo '.';
243 243
                 $nextStep += 8192;
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
     protected function renameMasterToPackage($file, $subPath, $path, $exclude): void
263 263
     {
264 264
         if (ends_with($file, 'master.zip')) {
265
-            $dir = coollect(scandir($path))->filter(function ($file) use ($exclude) {
265
+            $dir = coollect(scandir($path))->filter(function($file) use ($exclude) {
266 266
                 return $file !== '.' && $file !== '..' && $file !== $exclude;
267 267
             })->first();
268 268
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
     {
279 279
         $path = dirname($file);
280 280
 
281
-        if (! ends_with($file, '.zip') || file_exists($subPath = "$path/$subPath")) {
281
+        if (!ends_with($file, '.zip') || file_exists($subPath = "$path/$subPath")) {
282 282
             return;
283 283
         }
284 284
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
      */
298 298
     public function delTree($dir)
299 299
     {
300
-        if (! file_exists($dir)) {
300
+        if (!file_exists($dir)) {
301 301
             return false;
302 302
         }
303 303
 
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
 
335 335
         unset($shapeRecords);
336 336
 
337
-        return coollect($result)->mapWithKeys(function ($fields, $key1) {
337
+        return coollect($result)->mapWithKeys(function($fields, $key1) {
338 338
             return [
339
-                strtolower($key1) => coollect($fields)->mapWithKeys(function ($value, $key2) {
339
+                strtolower($key1) => coollect($fields)->mapWithKeys(function($value, $key2) {
340 340
                     return [strtolower($key2) => $value];
341 341
                 }),
342 342
             ];
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 
356 356
         $array = arrayable($array) ? $array->toArray() : $array;
357 357
 
358
-        array_walk($array, function ($value, $key) use (&$result) {
358
+        array_walk($array, function($value, $key) use (&$result) {
359 359
             $result[snake_case($key)] = arrayable($value) || is_array($value)
360 360
                 ? $this->arrayKeysSnakeRecursive($value)
361 361
                 : $value;
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
      */
384 384
     public function fixUtf8($string)
385 385
     {
386
-        return preg_replace_callback('/\\\\u([0-9a-fA-F]{4})/', function ($match) {
386
+        return preg_replace_callback('/\\\\u([0-9a-fA-F]{4})/', function($match) {
387 387
             return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
388 388
         }, $string);
389 389
     }
@@ -419,9 +419,9 @@  discard block
 block discarded – undo
419 419
      */
420 420
     public function downloadDataFiles()
421 421
     {
422
-        $this->config->get('downloadable')->each(function ($urls, $path) {
423
-            if (! file_exists($destination = $this->dataDir("third-party/$path"))) {
424
-                coollect($urls)->each(function ($url) use ($path, $destination) {
422
+        $this->config->get('downloadable')->each(function($urls, $path) {
423
+            if (!file_exists($destination = $this->dataDir("third-party/$path"))) {
424
+                coollect($urls)->each(function($url) use ($path, $destination) {
425 425
                     $this->download($url, $destination);
426 426
 
427 427
                     $file = basename($url);
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
      */
486 486
     public function loadJsonFiles($dir)
487 487
     {
488
-        return coollect(glob("$dir/*.json*"))->mapWithKeys(function ($file) {
488
+        return coollect(glob("$dir/*.json*"))->mapWithKeys(function($file) {
489 489
             $key = str_replace('.json', '', str_replace('.json5', '', basename($file)));
490 490
 
491 491
             return [$key => $this->loadJson($file)];
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
      */
519 519
     public function moveDataFiles()
520 520
     {
521
-        $this->config->get('moveable')->each(function ($to, $from) {
521
+        $this->config->get('moveable')->each(function($to, $from) {
522 522
             $this->moveDataFile($from, $to);
523 523
         });
524 524
     }
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
      */
548 548
     public function message($message, $type = 'line')
549 549
     {
550
-        if (! is_null($this->command)) {
550
+        if (!is_null($this->command)) {
551 551
             $this->command->{$type}($message);
552 552
         }
553 553
     }
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
             $this->abort('loadCsv Error: File name not set');
578 578
         }
579 579
 
580
-        if (! file_exists($file)) {
580
+        if (!file_exists($file)) {
581 581
             $file = $this->dataDir($this->addSuffix('.csv', "/$dir/".strtolower($file)));
582 582
         }
583 583
 
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
      */
594 594
     public function makeJsonFileName($key, $dir = '')
595 595
     {
596
-        if (! ends_with($dir, (DIRECTORY_SEPARATOR))) {
596
+        if (!ends_with($dir, (DIRECTORY_SEPARATOR))) {
597 597
             $dir .= DIRECTORY_SEPARATOR;
598 598
         }
599 599
 
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
     {
675 675
         $this->progress('--- Delete temporary files');
676 676
 
677
-        $this->config->get('deletable')->each(function ($directory) {
677
+        $this->config->get('deletable')->each(function($directory) {
678 678
             if (file_exists($directory = $this->dataDir($directory))) {
679 679
                 $this->deleteDirectory($directory);
680 680
             }
Please login to merge, or discard this patch.