Completed
Push — master ( fe980b...b1076e )
by Antonio Carlos
10:22
created
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/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/Taxes.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
         $taxes = $this->helper->loadJsonFiles($this->helper->dataDir('third-party/commerceguys/taxes/types'));
40 40
 
41
-        $taxes = $taxes->mapWithKeys(function ($vat, $key) {
41
+        $taxes = $taxes->mapWithKeys(function($vat, $key) {
42 42
             $parts = coollect(explode('_', $key));
43 43
             $cca2 = $parts->first();
44 44
             $type = $parts->last();
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
 
70 70
         $this->helper->message('Processing taxes...');
71 71
 
72
-        $normalizerClosure = function ($item) {
72
+        $normalizerClosure = function($item) {
73 73
             return $item;
74 74
         };
75 75
 
76
-        $getCodeClosure = function ($item) {
76
+        $getCodeClosure = function($item) {
77 77
             return $item['tax_type'];
78 78
         };
79 79
 
80
-        $generateTaxData = function ($tax) {
80
+        $generateTaxData = function($tax) {
81 81
             return $this->normalizeTax($tax);
82 82
         };
83 83
 
Please login to merge, or discard this patch.
src/update/Timezones.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         $countries = $this->cache->remember(
51 51
             'updateTimezone.countries',
52 52
             160,
53
-            function () {
53
+            function() {
54 54
                 return $this->helper->loadCsv($this->helper->dataDir('third-party/timezonedb/country.csv'));
55 55
             }
56 56
         );
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
         $zones = $this->cache->remember(
61 61
             'updateTimezone.zones',
62 62
             160,
63
-            function () {
64
-                return $this->helper->loadCsv($this->helper->dataDir('third-party/timezonedb/zone.csv'))->mapWithKeys(function ($value) {
63
+            function() {
64
+                return $this->helper->loadCsv($this->helper->dataDir('third-party/timezonedb/zone.csv'))->mapWithKeys(function($value) {
65 65
                     return [
66 66
                         $value[0] => [
67 67
                             'zone_id'      => $value[0],
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
         $timezones = $this->cache->remember(
79 79
             'updateTimezone.timezones',
80 80
             160,
81
-            function () {
82
-                return $this->helper->loadCsv($this->helper->dataDir('third-party/timezonedb/timezone.csv'))->map(function ($timezone) {
81
+            function() {
82
+                return $this->helper->loadCsv($this->helper->dataDir('third-party/timezonedb/timezone.csv'))->map(function($timezone) {
83 83
                     return [
84 84
                         'zone_id' => $timezone[0],
85 85
                         'abbreviation' => $timezone[1],
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
         $abbreviations = $this->cache->remember(
97 97
             'updateTimezone.abbreviations',
98 98
             160,
99
-            function () use ($timezones) {
100
-                return $timezones->groupBy('zone_id')->map(function (Coollection $timezones) {
101
-                    return $timezones->map(function ($timezone) {
99
+            function() use ($timezones) {
100
+                return $timezones->groupBy('zone_id')->map(function(Coollection $timezones) {
101
+                    return $timezones->map(function($timezone) {
102 102
                         return $timezone['abbreviation'];
103 103
                     })->unique()->sort()->values();
104 104
                 });
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
 
108 108
         $this->helper->progress('Updating countries timezones...');
109 109
 
110
-        $countries = $countries->mapWithKeys(function ($item) {
110
+        $countries = $countries->mapWithKeys(function($item) {
111 111
             return [$item[0] => [
112 112
                 'cca2' => $item[0],
113 113
                 'name' => $item[1],
114 114
             ]];
115 115
         })
116
-        ->mapWithKeys(function ($item, $cca2) {
116
+        ->mapWithKeys(function($item, $cca2) {
117 117
             $fields = [
118 118
                ['cca2', 'cca2'],
119 119
                ['name.common', 'name'],
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
                    'name' => $item['name'],
134 134
                ],
135 135
             ];
136
-        })->map(function ($country) use ($zones, $abbreviations) {
137
-            $country['timezones'] = $zones->where('country_code', $country['cca2'])->mapWithKeys(function ($zone) use ($abbreviations, $country) {
136
+        })->map(function($country) use ($zones, $abbreviations) {
137
+            $country['timezones'] = $zones->where('country_code', $country['cca2'])->mapWithKeys(function($zone) use ($abbreviations, $country) {
138 138
                 $zone['abbreviations'] = $abbreviations[$zone['zone_id']];
139 139
 
140 140
                 $zone['cca3'] = isset($country['cca3']) ? $country['cca3'] : null;
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
 
154 154
         $this->helper->message('Generating timezone files...');
155 155
 
156
-        $getCountryCodeClosure = function () {
156
+        $getCountryCodeClosure = function() {
157 157
         };
158 158
 
159
-        $normalizeCountryClosure = function ($country) {
159
+        $normalizeCountryClosure = function($country) {
160 160
             return [$country['timezones']];
161 161
         };
162 162
 
163
-        $dummyClosure = function ($country) {
163
+        $dummyClosure = function($country) {
164 164
             return $country;
165 165
         };
166 166
 
Please login to merge, or discard this patch.
src/update/Updater.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
             $record = $record->toArray();
210 210
         }
211 211
 
212
-        if (! isset($record[$field = 'data_sources'])) {
212
+        if (!isset($record[$field = 'data_sources'])) {
213 213
             $record['data_sources'] = [];
214 214
         }
215 215
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
         foreach ($fields as $field) {
268 268
             $found = $on->where($field[0], $by[$field[1]])->first();
269 269
 
270
-            if (isset($by[$field[1]]) && ! is_null($found) && $found->count() > 0) {
270
+            if (isset($by[$field[1]]) && !is_null($found) && $found->count() > 0) {
271 271
                 return [coollect($found), $found->{$codeField}];
272 272
             }
273 273
         }
@@ -285,19 +285,19 @@  discard block
 block discarded – undo
285 285
      */
286 286
     public function generateAllJsonFiles($dir, $makeGroupKeyClosure, $records, $groupKey)
287 287
     {
288
-        if (! empty($groupKey)) {
288
+        if (!empty($groupKey)) {
289 289
             $records = $records->groupBy($groupKey);
290 290
         }
291 291
 
292
-        $records->each(function (Coollection $record, $key) use ($dir, $makeGroupKeyClosure) {
292
+        $records->each(function(Coollection $record, $key) use ($dir, $makeGroupKeyClosure) {
293 293
             $this->helper->mkdir(dirname($file = $this->helper->makeJsonFileName($key, $dir)));
294 294
 
295
-            $record = $record->mapWithKeys(function ($record, $key) use ($makeGroupKeyClosure) {
295
+            $record = $record->mapWithKeys(function($record, $key) use ($makeGroupKeyClosure) {
296 296
                 $key = is_null($makeGroupKeyClosure)
297 297
                     ? $key
298 298
                     : $makeGroupKeyClosure($record, $key);
299 299
 
300
-                $record = coollect($record)->sortBy(function ($value, $key) {
300
+                $record = coollect($record)->sortBy(function($value, $key) {
301 301
                     return $key;
302 302
                 });
303 303
 
@@ -351,13 +351,13 @@  discard block
 block discarded – undo
351 351
         return $this->cache->remember(
352 352
             'normalizeData'.$dir,
353 353
             160,
354
-            function () use ($dir, $result, $normalizerClosure, &$counter) {
355
-                return coollect($result)->map(function ($item, $key) use ($normalizerClosure, &$counter) {
354
+            function() use ($dir, $result, $normalizerClosure, &$counter) {
355
+                return coollect($result)->map(function($item, $key) use ($normalizerClosure, &$counter) {
356 356
                     if ($counter++ % 1000 === 0) {
357 357
                         $this->helper->message("Normalized: {$counter}");
358 358
                     }
359 359
 
360
-                    return $normalizerClosure(coollect($item)->mapWithKeys(function ($value, $key) {
360
+                    return $normalizerClosure(coollect($item)->mapWithKeys(function($value, $key) {
361 361
                         return [strtolower($key) => $value];
362 362
                     }), $key);
363 363
                 });
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
             $countryCode = $this->helper->caseForKey($item['name']);
387 387
         }
388 388
 
389
-        $item['iso_a3'] = ! isset($item['iso_a3'])
389
+        $item['iso_a3'] = !isset($item['iso_a3'])
390 390
             ? $countryCode
391 391
             : $item['iso_a3'];
392 392
 
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
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
         $this->helper->message('Processing states...');
50 50
 
51
-        $normalizerClosure = function ($item) {
51
+        $normalizerClosure = function($item) {
52 52
             $item = $this->updater->addDataSource($item, 'natural');
53 53
 
54 54
             $item = $this->updater->addRecordType($item, 'state');
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
             return $this->updater->normalizeStateOrCityData($item);
57 57
         };
58 58
 
59
-        $getCodeClosure = function ($item) {
59
+        $getCodeClosure = function($item) {
60 60
             return $this->makeStatePostalCode($item);
61 61
         };
62 62
 
63 63
         $counter = 0;
64 64
 
65
-        $mergerClosure = function ($states) use (&$counter) {
65
+        $mergerClosure = function($states) use (&$counter) {
66 66
             if ($counter++ % 100 === 0) {
67 67
                 $this->helper->message("Processed: $counter");
68 68
             }
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             }
94 94
         }
95 95
 
96
-        if (! empty(trim($item->postal))) {
96
+        if (!empty(trim($item->postal))) {
97 97
             $item->postal;
98 98
         }
99 99
 
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
@@ -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.