Completed
Push — master ( f2ed00...07b62e )
by Antonio Carlos
05:36
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/package/Services/Config.php 1 patch
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     /**
17 17
      * Config constructor.
18 18
      *
19
-     * @param array|null $config
19
+     * @param Helper $config
20 20
      */
21 21
     public function __construct($config = null)
22 22
     {
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     }
25 25
 
26 26
     /**
27
-     * @param $key
27
+     * @param string $key
28 28
      * @return \PragmaRX\Coollection\Package\Coollection
29 29
      */
30 30
     public function get($key)
Please login to merge, or discard this patch.
src/package/Services/Countries.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -235,7 +235,7 @@
 block discarded – undo
235 235
     }
236 236
 
237 237
     /**
238
-     * @param $repository
238
+     * @param null|Repository $repository
239 239
      * @return Repository
240 240
      */
241 241
     protected function instantiateRepository($repository)
Please login to merge, or discard this patch.
Unused Use Statements   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,10 +2,10 @@
 block discarded – undo
2 2
 
3 3
 namespace PragmaRX\Countries\Package\Services;
4 4
 
5
-use PragmaRX\Countries\Update\Updater;
6
-use PragmaRX\Countries\Package\Support\Base;
7 5
 use PragmaRX\Coollection\Package\Coollection;
8 6
 use PragmaRX\Countries\Package\Data\Repository;
7
+use PragmaRX\Countries\Package\Support\Base;
8
+use PragmaRX\Countries\Update\Updater;
9 9
 
10 10
 class Countries extends Base
11 11
 {
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
     {
103 103
         $instance = $this;
104 104
 
105
-        Coollection::macro('hydrate', function ($elements = null) use ($instance) {
105
+        Coollection::macro('hydrate', function($elements = null) use ($instance) {
106 106
             return $instance->hydrate($this, $elements);
107 107
         });
108 108
 
109 109
         foreach (Hydrator::HYDRATORS as $hydrator) {
110 110
             $hydrator = 'hydrate'.studly_case($hydrator);
111 111
 
112
-            Coollection::macro($hydrator, function () use ($hydrator, $instance) {
112
+            Coollection::macro($hydrator, function() use ($hydrator, $instance) {
113 113
                 return $instance->getRepository()->getHydrator()->{$hydrator}($this);
114 114
             });
115 115
         }
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
      */
176 176
     protected function instantiateCache(Cache $cache = null)
177 177
     {
178
-        if (is_null($this->cache) || ! is_null($cache)) {
179
-            $this->cache = ! is_null($cache)
178
+        if (is_null($this->cache) || !is_null($cache)) {
179
+            $this->cache = !is_null($cache)
180 180
                 ? $cache
181 181
                 : new Cache($this->config);
182 182
         }
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
      */
193 193
     protected function instantiateConfig($config = null)
194 194
     {
195
-        if (is_null($this->config) || ! is_null($config)) {
196
-            $this->config = ! is_null($config)
195
+        if (is_null($this->config) || !is_null($config)) {
196
+            $this->config = !is_null($config)
197 197
                 ? $config
198 198
                 : new Config($this->helper);
199 199
         }
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
      */
225 225
     protected function instantiateHydrator(Hydrator $hydrator = null)
226 226
     {
227
-        if (is_null($this->hydrator) || ! is_null($hydrator)) {
228
-            $this->hydrator = ! is_null($hydrator)
227
+        if (is_null($this->hydrator) || !is_null($hydrator)) {
228
+            $this->hydrator = !is_null($hydrator)
229 229
                 ? $hydrator
230 230
                 : new Hydrator($this->config);
231 231
         }
Please login to merge, or discard this patch.
src/update/Updater.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     }
126 126
 
127 127
     /**
128
-     * @return mixed
128
+     * @return Command
129 129
      */
130 130
     public function getCommand()
131 131
     {
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
     }
205 205
 
206 206
     /**
207
-     * @param $result
208
-     * @param $type
207
+     * @param Coollection $result
208
+     * @param string $type
209 209
      * @return \PragmaRX\Coollection\Package\Coollection
210 210
      */
211 211
     public function addRecordType($result, $type)
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
      * @param \PragmaRX\Coollection\Package\Coollection $on
245 245
      * @param \PragmaRX\Coollection\Package\Coollection $by
246 246
      * @param $fields
247
-     * @param $codeField
247
+     * @param string $codeField
248 248
      * @return array
249 249
      */
250 250
     public function findByFields($on, $by, $fields, $codeField)
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
     /**
325 325
      * @param $result
326 326
      * @param $dir
327
-     * @param $normalizerClosure
327
+     * @param Closure $normalizerClosure
328 328
      * @return array
329 329
      */
330 330
     public function normalizeData($result, $dir, $normalizerClosure)
Please login to merge, or discard this patch.
Unused Use Statements   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,13 +3,12 @@
 block discarded – undo
3 3
 namespace PragmaRX\Countries\Update;
4 4
 
5 5
 use Closure;
6
-use PragmaRX\Countries\Package\Support\Base;
7 6
 use PragmaRX\Coollection\Package\Coollection;
7
+use PragmaRX\Countries\Package\Contracts\Config as ConfigContract;
8 8
 use PragmaRX\Countries\Package\Services\Cache;
9
-use PragmaRX\Countries\Package\Contracts\Config;
10 9
 use PragmaRX\Countries\Package\Services\Command;
11 10
 use PragmaRX\Countries\Package\Services\Config as ConfigService;
12
-use PragmaRX\Countries\Package\Contracts\Config as ConfigContract;
11
+use PragmaRX\Countries\Package\Support\Base;
13 12
 
14 13
 /**
15 14
  * @codeCoverageIgnore
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
             $record = $record->toArray();
195 195
         }
196 196
 
197
-        if (! isset($record[$field = 'data_sources'])) {
197
+        if (!isset($record[$field = 'data_sources'])) {
198 198
             $record['data_sources'] = [];
199 199
         }
200 200
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
     public function findByFields($on, $by, $fields, $codeField)
251 251
     {
252 252
         foreach ($fields as $field) {
253
-            if (isset($by[$field[1]]) && ! is_null($found = $on->where($field[0], $by[$field[1]])->first())) {
253
+            if (isset($by[$field[1]]) && !is_null($found = $on->where($field[0], $by[$field[1]])->first())) {
254 254
                 return [coollect($found), $found->{$codeField}];
255 255
             }
256 256
         }
@@ -268,19 +268,19 @@  discard block
 block discarded – undo
268 268
      */
269 269
     public function generateAllJsonFiles($dir, $makeGroupKeyClosure, $records, $groupKey)
270 270
     {
271
-        if (! empty($groupKey)) {
271
+        if (!empty($groupKey)) {
272 272
             $records = $records->groupBy($groupKey);
273 273
         }
274 274
 
275
-        $records->each(function (Coollection $record, $key) use ($dir, $makeGroupKeyClosure) {
275
+        $records->each(function(Coollection $record, $key) use ($dir, $makeGroupKeyClosure) {
276 276
             $this->helper->mkdir(dirname($file = $this->helper->makeJsonFileName($key, $dir)));
277 277
 
278
-            $record = $record->mapWithKeys(function ($record, $key) use ($makeGroupKeyClosure) {
278
+            $record = $record->mapWithKeys(function($record, $key) use ($makeGroupKeyClosure) {
279 279
                 $key = is_null($makeGroupKeyClosure)
280 280
                     ? $key
281 281
                     : $makeGroupKeyClosure($record, $key);
282 282
 
283
-                $record = coollect($record)->sortBy(function ($value, $key) {
283
+                $record = coollect($record)->sortBy(function($value, $key) {
284 284
                     return $key;
285 285
                 });
286 286
 
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
         return $this->cache->remember(
333 333
             'normalizeData'.$dir,
334 334
             160,
335
-            function () use ($dir, $result, $normalizerClosure) {
336
-                return coollect($result)->map(function ($item, $key) use ($normalizerClosure) {
337
-                    return $normalizerClosure(coollect($item)->mapWithKeys(function ($value, $key) {
335
+            function() use ($dir, $result, $normalizerClosure) {
336
+                return coollect($result)->map(function($item, $key) use ($normalizerClosure) {
337
+                    return $normalizerClosure(coollect($item)->mapWithKeys(function($value, $key) {
338 338
                         return [strtolower($key) => $value];
339 339
                     }), $key);
340 340
                 });
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
             $countryCode = $this->helper->caseForKey($item['name']);
364 364
         }
365 365
 
366
-        $item['iso_a3'] = ! isset($item['iso_a3'])
366
+        $item['iso_a3'] = !isset($item['iso_a3'])
367 367
             ? $countryCode
368 368
             : $item['iso_a3'];
369 369
 
Please login to merge, or discard this patch.
src/update/Rinvex.php 3 patches
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.
Unused Use Statements   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@
 block discarded – undo
3 3
 namespace PragmaRX\Countries\Update;
4 4
 
5 5
 use Exception;
6
-use PragmaRX\Countries\Package\Support\Base;
7 6
 use PragmaRX\Coollection\Package\Coollection;
7
+use PragmaRX\Countries\Package\Support\Base;
8 8
 
9 9
 class Rinvex extends Base
10 10
 {
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@
 block discarded – undo
157 157
      *
158 158
      * @param Coollection $natural
159 159
      * @param Coollection $rinvex
160
-     * @param $translation
160
+     * @param null|Coollection $translation
161 161
      * @param string $suffix
162 162
      * @return mixed|\PragmaRX\Coollection\Package\Coollection
163 163
      */
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 3 patches
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.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@
 block discarded – undo
83 83
     /**
84 84
      * Build countries collection.
85 85
      *
86
-     * @param $dataDir
86
+     * @param string $dataDir
87 87
      * @return \PragmaRX\Coollection\Package\Coollection
88 88
      */
89 89
     public function buildCountriesCoollection($dataDir)
Please login to merge, or discard this patch.
Unused Use Statements   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,10 +2,10 @@
 block discarded – undo
2 2
 
3 3
 namespace PragmaRX\Countries\Update;
4 4
 
5
-use PragmaRX\Countries\Package\Support\Base;
5
+use PragmaRX\Countries\Package\Countries as CountriesService;
6 6
 use PragmaRX\Countries\Package\Services\Cache;
7 7
 use PragmaRX\Countries\Package\Services\Config;
8
-use PragmaRX\Countries\Package\Countries as CountriesService;
8
+use PragmaRX\Countries\Package\Support\Base;
9 9
 
10 10
 class Countries extends Base
11 11
 {
Please login to merge, or discard this patch.
src/update/Mledoze.php 3 patches
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.
Unused Use Statements   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@
 block discarded – undo
2 2
 
3 3
 namespace PragmaRX\Countries\Update;
4 4
 
5
-use PragmaRX\Countries\Package\Support\Base;
6 5
 use PragmaRX\Coollection\Package\Coollection;
6
+use PragmaRX\Countries\Package\Support\Base;
7 7
 
8 8
 class Mledoze extends Base
9 9
 {
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      * Fill mledoze fields with natural earth vector data.
61 61
      *
62 62
      * @param $fields
63
-     * @return mixed
63
+     * @return Coollection
64 64
      */
65 65
     public function fillMledozeFields($fields)
66 66
     {
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      * @param \PragmaRX\Coollection\Package\Coollection $mledoze
111 111
      * @param \PragmaRX\Coollection\Package\Coollection $natural
112 112
      * @param string $suffix
113
-     * @return mixed
113
+     * @return Coollection
114 114
      */
115 115
     public function mergeWithMledoze($mledoze, $natural, $suffix = '_nev')
116 116
     {
Please login to merge, or discard this patch.