@@ -99,7 +99,7 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -2,7 +2,7 @@ discard block |
||
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 |
||
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 |
||
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 | * |
@@ -16,7 +16,7 @@ discard block |
||
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 |
||
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) |
@@ -235,7 +235,7 @@ |
||
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) |
@@ -2,10 +2,10 @@ |
||
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 | { |
@@ -102,14 +102,14 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -61,7 +61,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | * Merge country data with Rinvex data. |
157 | 157 | * |
158 | 158 | * @param Coollection $natural |
159 | - * @param Coollection $rinvex |
|
160 | - * @param $translation |
|
159 | + * @param null|Coollection $rinvex |
|
160 | + * @param null|Coollection $translation |
|
161 | 161 | * @param string $suffix |
162 | 162 | * @return mixed|\PragmaRX\Coollection\Package\Coollection |
163 | 163 | */ |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
262 | - * @param \PragmaRX\Coollection\Package\Coollection $rinvex |
|
262 | + * @param null|Coollection $rinvex |
|
263 | 263 | * @param $cca3 |
264 | 264 | * @param $postal |
265 | 265 | * @param $country |
@@ -3,8 +3,8 @@ |
||
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 | { |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | }) |
102 | 102 | ->mapWithKeys(function ($item, $cca2) { |
103 | 103 | $fields = [ |
104 | - ['cca2', 'cca2'], |
|
105 | - ['name.common', 'name'], |
|
106 | - ['name.official', 'name'], |
|
104 | + ['cca2', 'cca2'], |
|
105 | + ['name.common', 'name'], |
|
106 | + ['name.official', 'name'], |
|
107 | 107 | ]; |
108 | 108 | |
109 | 109 | list($country) = $this->updater->findByFields($this->updater->getCountries(), $item, $fields, 'cca2'); |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | return [ |
116 | - $country->cca3 => [ |
|
117 | - 'cca2' => $country->cca2, |
|
118 | - 'cca3' => $country->cca3, |
|
119 | - 'name' => $item['name'], |
|
120 | - ], |
|
116 | + $country->cca3 => [ |
|
117 | + 'cca2' => $country->cca2, |
|
118 | + 'cca3' => $country->cca3, |
|
119 | + 'name' => $item['name'], |
|
120 | + ], |
|
121 | 121 | ]; |
122 | 122 | })->map(function ($country) use ($zones, $abbreviations) { |
123 | 123 | $country['timezones'] = $zones->where('country_code', $country['cca2'])->mapWithKeys(function ($zone) use ($abbreviations, $country) { |
@@ -2,10 +2,10 @@ |
||
2 | 2 | |
3 | 3 | namespace PragmaRX\Countries\Update; |
4 | 4 | |
5 | -use PragmaRX\Countries\Package\Support\Base; |
|
6 | 5 | use PragmaRX\Coollection\Package\Coollection; |
7 | 6 | use PragmaRX\Countries\Package\Services\Cache; |
8 | 7 | use PragmaRX\Countries\Package\Services\Config; |
8 | +use PragmaRX\Countries\Package\Support\Base; |
|
9 | 9 | |
10 | 10 | class Timezones extends Base |
11 | 11 | { |
@@ -50,7 +50,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -43,7 +43,7 @@ discard block |
||
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 |
||
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 |
@@ -47,13 +47,13 @@ discard block |
||
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 |
||
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 |
@@ -38,7 +38,7 @@ discard block |
||
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 |
||
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 |