Completed
Push — master ( 1590f4...bc7ce7 )
by Antonio Carlos
32s queued 12s
created
src/package/Services/Helper.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
             throw new Exception('loadJson Error: File name not set');
49 49
         }
50 50
 
51
-        if (! file_exists($file) && ! file_exists($file = $this->dataDir("/$dir/".strtolower($file).'.json'))) {
51
+        if (!file_exists($file) && !file_exists($file = $this->dataDir("/$dir/".strtolower($file).'.json'))) {
52 52
             return coollect();
53 53
         }
54 54
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function loadJsonFiles($dir)
71 71
     {
72
-        return coollect(glob("$dir/*.json*"))->mapWithKeys(function ($file) {
72
+        return coollect(glob("$dir/*.json*"))->mapWithKeys(function($file) {
73 73
             $key = str_replace(['.json5', '.json'], '', basename($file));
74 74
 
75 75
             return [$key => $this->loadJson($file)];
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function moveFilesWildcard($from, $to)
86 86
     {
87
-        coollect(glob($this->dataDir($from)))->each(function ($from) use ($to) {
87
+        coollect(glob($this->dataDir($from)))->each(function($from) use ($to) {
88 88
             $this->mkDir($dir = $this->dataDir($to));
89 89
 
90 90
             rename($from, $dir.'/'.basename($from));
Please login to merge, or discard this patch.
src/update/Nationality.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function load()
37 37
     {
38
-        $mledoze = coollect($this->helper->loadJson('countries', 'third-party/mledoze/dist'))->mapWithKeys(function (
38
+        $mledoze = coollect($this->helper->loadJson('countries', 'third-party/mledoze/dist'))->mapWithKeys(function(
39 39
             $country
40 40
         ) {
41 41
             $country = $this->updater->addDataSource($country, 'mledoze');
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     {
90 90
         [$country, $countryCode] = $this->updater->findCountryByAnyField($mledoze, $natural);
91 91
 
92
-        if (! $country->isEmpty()) {
92
+        if (!$country->isEmpty()) {
93 93
             return [coollect($this->helper->arrayKeysSnakeRecursive($country)), $countryCode];
94 94
         }
95 95
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
             $result[$key] = $mledozeValue; // Natural Earth Vector
138 138
         }
139 139
 
140
-        return coollect($result)->sortBy(function ($value, $key) {
140
+        return coollect($result)->sortBy(function($value, $key) {
141 141
             return $key;
142 142
         });
143 143
     }
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
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function loadMledozeCountries()
45 45
     {
46
-        $mledoze = coollect($this->helper->loadJson('countries', 'third-party/mledoze/dist'))->mapWithKeys(function (
46
+        $mledoze = coollect($this->helper->loadJson('countries', 'third-party/mledoze/dist'))->mapWithKeys(function(
47 47
             $country
48 48
         ) {
49 49
             $country = $this->updater->addDataSource($country, 'mledoze');
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     {
98 98
         [$country, $countryCode] = $this->updater->findCountryByAnyField($mledoze, $natural);
99 99
 
100
-        if (! $country->isEmpty()) {
100
+        if (!$country->isEmpty()) {
101 101
             return [coollect($this->helper->arrayKeysSnakeRecursive($country)), $countryCode];
102 102
         }
103 103
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
         $result = $this->makeFlag($result);
158 158
 
159
-        return coollect($result)->sortBy(function ($value, $key) {
159
+        return coollect($result)->sortBy(function($value, $key) {
160 160
             return $key;
161 161
         });
162 162
     }
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);
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 
105 105
         $this->helper->message('Generating countries...');
106 106
 
107
-        $countries = coollect($shapeFile)->map(function ($country) {
107
+        $countries = coollect($shapeFile)->map(function($country) {
108 108
             return $this->natural->fixNaturalOddCountries($country);
109
-        })->mapWithKeys(function ($natural) use ($mledoze, $dataDir) {
109
+        })->mapWithKeys(function($natural) use ($mledoze, $dataDir) {
110 110
             [$mledoze, $countryCode] = $this->mledoze->findMledozeCountry($mledoze, $natural);
111 111
 
112
-            $natural = coollect($natural)->mapWithKeys(function ($country, $key) {
112
+            $natural = coollect($natural)->mapWithKeys(function($country, $key) {
113 113
                 return [strtolower($key) => $country];
114 114
             });
115 115
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
     public function clearCountryCurrencies($country)
152 152
     {
153
-        if (isset($country['currency']) && ! is_null($country['currency'])) {
153
+        if (isset($country['currency']) && !is_null($country['currency'])) {
154 154
             $country['currencies'] = $country['currency']->keys();
155 155
 
156 156
             unset($country['currency']);
Please login to merge, or discard this patch.
src/package/Services/Countries.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
     {
107 107
         $instance = $this;
108 108
 
109
-        Coollection::macro('hydrate', function ($elements = null) use ($instance) {
109
+        Coollection::macro('hydrate', function($elements = null) use ($instance) {
110 110
             return $instance->hydrate($this, $elements);
111 111
         });
112 112
 
113 113
         foreach (Hydrator::HYDRATORS as $hydrator) {
114 114
             $hydrator = 'hydrate'.Str::studly($hydrator);
115 115
 
116
-            Coollection::macro($hydrator, function () use ($hydrator, $instance) {
116
+            Coollection::macro($hydrator, function() use ($hydrator, $instance) {
117 117
                 return $instance->getRepository()->getHydrator()->{$hydrator}($this);
118 118
             });
119 119
         }
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
      */
180 180
     protected function instantiateCache(Cache $cache = null)
181 181
     {
182
-        if (\is_null($this->cache) || ! \is_null($cache)) {
183
-            $this->cache = ! \is_null($cache)
182
+        if (\is_null($this->cache) || !\is_null($cache)) {
183
+            $this->cache = !\is_null($cache)
184 184
                 ? $cache
185 185
                 : new Cache($this->config);
186 186
         }
@@ -196,8 +196,8 @@  discard block
 block discarded – undo
196 196
      */
197 197
     protected function instantiateConfig($config = null)
198 198
     {
199
-        if (\is_null($this->config) || ! \is_null($config)) {
200
-            $this->config = ! \is_null($config)
199
+        if (\is_null($this->config) || !\is_null($config)) {
200
+            $this->config = !\is_null($config)
201 201
                 ? $config
202 202
                 : new Config($this->helper);
203 203
         }
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
      */
229 229
     protected function instantiateHydrator(Hydrator $hydrator = null)
230 230
     {
231
-        if (\is_null($this->hydrator) || ! \is_null($hydrator)) {
232
-            $this->hydrator = ! \is_null($hydrator)
231
+        if (\is_null($this->hydrator) || !\is_null($hydrator)) {
232
+            $this->hydrator = !\is_null($hydrator)
233 233
                 ? $hydrator
234 234
                 : new Hydrator($this->config);
235 235
         }
Please login to merge, or discard this patch.
src/package/Data/Repository.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     {
149 149
         $this->countriesJson = $this->loadCountriesJson();
150 150
 
151
-        $overload = $this->helper->loadJsonFiles($this->helper->dataDir('countries/overload'))->mapWithKeys(function ($country, $code) {
151
+        $overload = $this->helper->loadJsonFiles($this->helper->dataDir('countries/overload'))->mapWithKeys(function($country, $code) {
152 152
             return [Str::upper($code) => $country];
153 153
         });
154 154
 
@@ -207,11 +207,11 @@  discard block
 block discarded – undo
207 207
      */
208 208
     public function currencies()
209 209
     {
210
-        $currencies = $this->helper->loadJsonFiles($this->helper->dataDir('currencies/default'))->mapWithKeys(function ($country, $code) {
210
+        $currencies = $this->helper->loadJsonFiles($this->helper->dataDir('currencies/default'))->mapWithKeys(function($country, $code) {
211 211
             return [Str::upper($code) => $country];
212 212
         });
213 213
 
214
-        $overload = $this->helper->loadJsonFiles($this->helper->dataDir('currencies/overload'))->mapWithKeys(function ($country, $code) {
214
+        $overload = $this->helper->loadJsonFiles($this->helper->dataDir('currencies/overload'))->mapWithKeys(function($country, $code) {
215 215
             return [Str::upper($code) => $country];
216 216
         });
217 217
 
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
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         $countries = $this->cache->remember(
52 52
             'updateTimezone.countries',
53 53
             160,
54
-            function () {
54
+            function() {
55 55
                 return $this->helper->loadCsv($this->helper->dataDir('third-party/timezonedb/country.csv'));
56 56
             }
57 57
         );
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
         $zones = $this->cache->remember(
62 62
             'updateTimezone.zones',
63 63
             160,
64
-            function () {
65
-                return $this->helper->loadCsv($this->helper->dataDir('third-party/timezonedb/zone.csv'))->mapWithKeys(function ($value) {
64
+            function() {
65
+                return $this->helper->loadCsv($this->helper->dataDir('third-party/timezonedb/zone.csv'))->mapWithKeys(function($value) {
66 66
                     return [
67 67
                         $value[0] => [
68 68
                             'zone_id'      => $value[0],
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
         $timezones = $this->cache->remember(
80 80
             'updateTimezone.timezones',
81 81
             160,
82
-            function () {
83
-                return $this->helper->loadCsv($this->helper->dataDir('third-party/timezonedb/timezone.csv'))->map(function ($timezone) {
82
+            function() {
83
+                return $this->helper->loadCsv($this->helper->dataDir('third-party/timezonedb/timezone.csv'))->map(function($timezone) {
84 84
                     return [
85 85
                         'zone_id' => $timezone[0],
86 86
                         'abbreviation' => $timezone[1],
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
         $abbreviations = $this->cache->remember(
98 98
             'updateTimezone.abbreviations',
99 99
             160,
100
-            function () use ($timezones) {
101
-                return $timezones->groupBy('zone_id')->map(function (Coollection $timezones) {
102
-                    return $timezones->map(function ($timezone) {
100
+            function() use ($timezones) {
101
+                return $timezones->groupBy('zone_id')->map(function(Coollection $timezones) {
102
+                    return $timezones->map(function($timezone) {
103 103
                         return $timezone['abbreviation'];
104 104
                     })->unique()->sort()->values();
105 105
                 });
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
 
109 109
         $this->helper->progress('Updating countries timezones...');
110 110
 
111
-        $countries = $countries->mapWithKeys(function ($item) {
111
+        $countries = $countries->mapWithKeys(function($item) {
112 112
             return [$item[0] => [
113 113
                 'cca2' => $item[0],
114 114
                 'name' => $item[1],
115 115
             ]];
116 116
         })
117
-        ->mapWithKeys(function ($item, $cca2) {
117
+        ->mapWithKeys(function($item, $cca2) {
118 118
             $fields = [
119 119
                 ['cca2', 'cca2'],
120 120
                 ['name.common', 'name'],
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
                     'name' => $item['name'],
135 135
                 ],
136 136
             ];
137
-        })->map(function ($country) use ($zones, $abbreviations) {
138
-            $country['timezones'] = $zones->where('country_code', $country['cca2'])->mapWithKeys(function ($zone) use ($abbreviations, $country) {
137
+        })->map(function($country) use ($zones, $abbreviations) {
138
+            $country['timezones'] = $zones->where('country_code', $country['cca2'])->mapWithKeys(function($zone) use ($abbreviations, $country) {
139 139
                 $zone['abbreviations'] = $abbreviations[$zone['zone_id']];
140 140
 
141 141
                 $zone['cca3'] = isset($country['cca3']) ? $country['cca3'] : null;
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
 
155 155
         $this->helper->message('Generating timezone files...');
156 156
 
157
-        $getCountryCodeClosure = function () {
157
+        $getCountryCodeClosure = function() {
158 158
         };
159 159
 
160
-        $normalizeCountryClosure = function ($country) {
160
+        $normalizeCountryClosure = function($country) {
161 161
             return [$country['timezones']];
162 162
         };
163 163
 
164
-        $dummyClosure = function ($country) {
164
+        $dummyClosure = function($country) {
165 165
             return $country;
166 166
         };
167 167
 
Please login to merge, or discard this patch.
src/package/Services/Hydrator.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     protected function canHydrate($element, $enabled, $countryCode)
65 65
     {
66 66
         return ($enabled || $this->config->get('hydrate.elements.'.$element)) &&
67
-                ! isset($this->repository->countries[$countryCode]['hydrated'][$element]);
67
+                !isset($this->repository->countries[$countryCode]['hydrated'][$element]);
68 68
     }
69 69
 
70 70
     /**
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     protected function createHydrated($countryCode)
74 74
     {
75
-        if (! isset($this->repository->countries[$countryCode]['hydrated'])) {
75
+        if (!isset($this->repository->countries[$countryCode]['hydrated'])) {
76 76
             $this->repository->countries[$countryCode]['hydrated'] = [];
77 77
         }
78 78
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
     protected function fixCurrencies($country)
83 83
     {
84
-        if (! isset($country['currencies']) && isset($country['currency'])) {
84
+        if (!isset($country['currencies']) && isset($country['currency'])) {
85 85
             $country['currencies'] = $country['currency'];
86 86
         }
87 87
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     private function hydrateCountries($countries, $elements = null)
99 99
     {
100 100
         return countriesCollect(
101
-            $countries->map(function ($country) use ($elements) {
101
+            $countries->map(function($country) use ($elements) {
102 102
                 return $this->hydrateCountry($country, $elements);
103 103
             })
104 104
         );
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      */
193 193
     protected function needsHydration($countryCode, $element, $enabled = false)
194 194
     {
195
-        if (! $this->canHydrate($element, $enabled, $countryCode)) {
195
+        if (!$this->canHydrate($element, $enabled, $countryCode)) {
196 196
             return false;
197 197
         }
198 198
 
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
     public function hydrateBorders($country)
306 306
     {
307 307
         $country['borders'] = isset($country['borders'])
308
-            ? $country['borders'] = countriesCollect($country['borders'])->map(function ($border) {
308
+            ? $country['borders'] = countriesCollect($country['borders'])->map(function($border) {
309 309
                 return $this->repository->call('where', ['cca3', $border])->first();
310 310
             })
311 311
             : countriesCollect();
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
     {
335 335
         $country = $this->hydrateTimezones($country);
336 336
 
337
-        $country['timezones'] = $country->timezones->map(function ($timezone) {
337
+        $country['timezones'] = $country->timezones->map(function($timezone) {
338 338
             return $timezone->overwrite(['times' => $this->repository->findTimezoneTime($timezone['zone_id'])]);
339 339
         });
340 340
 
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
         $country = $this->fixCurrencies($country);
355 355
 
356 356
         if (isset($country['currencies'])) {
357
-            $currencies = countriesCollect($country['currencies'])->mapWithKeys(function ($code, $currencyCode) {
357
+            $currencies = countriesCollect($country['currencies'])->mapWithKeys(function($code, $currencyCode) {
358 358
                 if ($this->isCurrenciesArray($code)) {
359 359
                     return [
360 360
                         $code['ISO4217Code'] => $code,
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
      */
416 416
     public function addCountry($countryCode, $country)
417 417
     {
418
-        if (! isset($this->repository->countries[$countryCode])) {
418
+        if (!isset($this->repository->countries[$countryCode])) {
419 419
             $this->repository->countries[$countryCode] = $country;
420 420
         }
421 421
     }
@@ -442,14 +442,14 @@  discard block
 block discarded – undo
442 442
      */
443 443
     protected function checkHydrationElements($elements)
444 444
     {
445
-        $elements = countriesCollect($elements)->mapWithKeys(function ($value, $key) {
445
+        $elements = countriesCollect($elements)->mapWithKeys(function($value, $key) {
446 446
             if (is_numeric($key)) {
447 447
                 $key = $value;
448 448
                 $value = true;
449 449
             }
450 450
 
451 451
             return [$key => $value];
452
-        })->filter(function ($element) {
452
+        })->filter(function($element) {
453 453
             return $element;
454 454
         });
455 455
 
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 ($result, $normalizerClosure, &$counter) {
355
-                return coollect($result)->map(function ($item, $key) use ($normalizerClosure, &$counter) {
354
+            function() use ($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.