@@ -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 |
@@ -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 | -use PragmaRX\Countries\Package\Services\Config; |
|
8 | 6 | use PragmaRX\Countries\Package\Services\Cache\Service as Cache; |
7 | +use PragmaRX\Countries\Package\Services\Config; |
|
8 | +use PragmaRX\Countries\Package\Support\Base; |
|
9 | 9 | |
10 | 10 | class Timezones extends Base |
11 | 11 | { |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | }) |
116 | 116 | ->mapWithKeys(function ($item, $cca2) { |
117 | 117 | $fields = [ |
118 | - ['cca2', 'cca2'], |
|
119 | - ['name.common', 'name'], |
|
120 | - ['name.official', 'name'], |
|
118 | + ['cca2', 'cca2'], |
|
119 | + ['name.common', 'name'], |
|
120 | + ['name.official', 'name'], |
|
121 | 121 | ]; |
122 | 122 | |
123 | 123 | [$country] = $this->updater->findByFields($this->updater->getCountries(), $item, $fields, 'cca2'); |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | return [ |
130 | - $country->cca3 => [ |
|
131 | - 'cca2' => $country->cca2, |
|
132 | - 'cca3' => $country->cca3, |
|
133 | - 'name' => $item['name'], |
|
134 | - ], |
|
130 | + $country->cca3 => [ |
|
131 | + 'cca2' => $country->cca2, |
|
132 | + 'cca3' => $country->cca3, |
|
133 | + 'name' => $item['name'], |
|
134 | + ], |
|
135 | 135 | ]; |
136 | 136 | })->map(function ($country) use ($zones, $abbreviations) { |
137 | 137 | $country['timezones'] = $zones->where('country_code', $country['cca2'])->mapWithKeys(function ($zone) use ($abbreviations, $country) { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param CacheContract $cache |
64 | 64 | * @param Hydrator $hydrator |
65 | 65 | * @param Helper $helper |
66 | - * @param object $config |
|
66 | + * @param \PragmaRX\Countries\Package\Services\Config $config |
|
67 | 67 | */ |
68 | 68 | public function __construct(CacheContract $cache, Hydrator $hydrator, Helper $helper, $config) |
69 | 69 | { |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * Load currency json file. |
180 | 180 | * |
181 | 181 | * @param $code |
182 | - * @return string |
|
182 | + * @return \PragmaRX\Coollection\Package\Coollection |
|
183 | 183 | */ |
184 | 184 | public function loadCurrenciesForCountry($code) |
185 | 185 | { |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * Find a country timezone. |
312 | 312 | * |
313 | 313 | * @param $countryCode |
314 | - * @return null |
|
314 | + * @return \PragmaRX\Coollection\Package\Coollection |
|
315 | 315 | */ |
316 | 316 | public function findTimezones($countryCode) |
317 | 317 | { |
@@ -3,10 +3,10 @@ |
||
3 | 3 | namespace PragmaRX\Countries\Package\Data; |
4 | 4 | |
5 | 5 | use IlluminateAgnostic\Str\Support\Str; |
6 | +use PragmaRX\Countries\Package\Services\Cache\Service as Cache; |
|
6 | 7 | use PragmaRX\Countries\Package\Services\Helper; |
7 | 8 | use PragmaRX\Countries\Package\Services\Hydrator; |
8 | 9 | use Psr\SimpleCache\CacheInterface as CacheContract; |
9 | -use PragmaRX\Countries\Package\Services\Cache\Service as Cache; |
|
10 | 10 | |
11 | 11 | class Repository |
12 | 12 | { |
@@ -148,7 +148,7 @@ discard block |
||
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 |
||
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 |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * Check if cache is enabled. |
51 | 51 | * |
52 | - * @return bool |
|
52 | + * @return \PragmaRX\Coollection\Package\Coollection |
|
53 | 53 | */ |
54 | 54 | protected function enabled() |
55 | 55 | { |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * Delete an item from the cache by its unique key. |
136 | 136 | * |
137 | 137 | * @param string $key |
138 | - * @return bool |
|
138 | + * @return boolean|null |
|
139 | 139 | */ |
140 | 140 | public function delete($key) |
141 | 141 | { |
@@ -3,10 +3,10 @@ |
||
3 | 3 | namespace PragmaRX\Countries\Package\Services\Cache\Managers; |
4 | 4 | |
5 | 5 | use Closure; |
6 | -use Psr\SimpleCache\CacheInterface; |
|
7 | 6 | use Nette\Caching\Cache as NetteCache; |
8 | 7 | use Nette\Caching\Storages\FileStorage; |
9 | 8 | use PragmaRX\Countries\Package\Services\Config; |
9 | +use Psr\SimpleCache\CacheInterface; |
|
10 | 10 | |
11 | 11 | class Nette implements CacheInterface |
12 | 12 | { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | if (\is_null($this->dir)) { |
63 | 63 | $this->dir = $this->config->cache->directory ?: sys_get_temp_dir().'/__PRAGMARX_COUNTRIES__/cache'; |
64 | 64 | |
65 | - if (! file_exists($this->dir)) { |
|
65 | + if (!file_exists($this->dir)) { |
|
66 | 66 | mkdir($this->dir, 0755, true); |
67 | 67 | } |
68 | 68 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function getMultiple($keys, $default = null) |
155 | 155 | { |
156 | - return coollect($keys)->map(function ($key) { |
|
156 | + return coollect($keys)->map(function($key) { |
|
157 | 157 | return $this->get($key); |
158 | 158 | }); |
159 | 159 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function setMultiple($values, $ttl = null) |
169 | 169 | { |
170 | - return coollect($values)->map(function ($value, $key) use ($ttl) { |
|
170 | + return coollect($values)->map(function($value, $key) use ($ttl) { |
|
171 | 171 | return $this->set($key, $value, $ttl); |
172 | 172 | }); |
173 | 173 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function deleteMultiple($keys) |
182 | 182 | { |
183 | - coollect($keys)->map(function ($key) { |
|
183 | + coollect($keys)->map(function($key) { |
|
184 | 184 | $this->forget($key); |
185 | 185 | }); |
186 | 186 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function has($key) |
195 | 195 | { |
196 | - return ! \is_null($this->get($key)); |
|
196 | + return !\is_null($this->get($key)); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | { |
209 | 209 | $value = $this->get($key); |
210 | 210 | |
211 | - if (! \is_null($value)) { |
|
211 | + if (!\is_null($value)) { |
|
212 | 212 | return $value; |
213 | 213 | } |
214 | 214 |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * Hydrator constructor. |
48 | 48 | * |
49 | - * @param object $config |
|
49 | + * @param Config $config |
|
50 | 50 | */ |
51 | 51 | public function __construct($config) |
52 | 52 | { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * Can hydrate? |
58 | 58 | * |
59 | 59 | * @param $element |
60 | - * @param $enabled |
|
60 | + * @param boolean $enabled |
|
61 | 61 | * @param $countryCode |
62 | 62 | * @return bool |
63 | 63 | */ |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @param $countries |
95 | 95 | * @param $elements |
96 | - * @return mixed |
|
96 | + * @return \PragmaRX\Countries\Package\Support\Collection |
|
97 | 97 | */ |
98 | 98 | private function hydrateCountries($countries, $elements = null) |
99 | 99 | { |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @param $country |
111 | 111 | * @param $elements |
112 | - * @return mixed |
|
112 | + * @return \PragmaRX\Countries\Package\Support\Collection |
|
113 | 113 | */ |
114 | 114 | private function hydrateCountry($country, $elements) |
115 | 115 | { |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * Hydrate flag. |
286 | 286 | * |
287 | 287 | * @param $country |
288 | - * @return mixed |
|
288 | + * @return Coollection |
|
289 | 289 | */ |
290 | 290 | public function hydrateFlag($country) |
291 | 291 | { |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | * Get country by country code. |
397 | 397 | * |
398 | 398 | * @param $countryCode |
399 | - * @return mixed |
|
399 | + * @return \PragmaRX\Countries\Package\Support\Collection |
|
400 | 400 | */ |
401 | 401 | public function getCountry($countryCode) |
402 | 402 | { |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | /** |
456 | 456 | * Repository setter. |
457 | 457 | * |
458 | - * @param $repository |
|
458 | + * @param \PragmaRX\Countries\Package\Data\Repository $repository |
|
459 | 459 | */ |
460 | 460 | public function setRepository($repository) |
461 | 461 | { |
@@ -64,7 +64,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
354 | 354 | $country = $this->fixCurrencies($country); |
355 | 355 | |
356 | 356 | if (isset($country['currencies'])) { |
357 | - $currencies = countriesCollect($country['currencies'])->mapWithKeys(function ($code, $currencyCode) use ($country) { |
|
357 | + $currencies = countriesCollect($country['currencies'])->mapWithKeys(function($code, $currencyCode) use ($country) { |
|
358 | 358 | if ($this->isCurrenciesArray($code)) { |
359 | 359 | return [ |
360 | 360 | $code['ISO4217Code'] => $code, |
@@ -415,7 +415,7 @@ discard block |
||
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 |
||
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 |
@@ -2,8 +2,8 @@ |
||
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 Nationality extends Base |
9 | 9 | { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * Fill mledoze fields with natural earth vector data. |
53 | 53 | * |
54 | - * @param $fields |
|
54 | + * @param Coollection $fields |
|
55 | 55 | * @return mixed |
56 | 56 | */ |
57 | 57 | public function fillMledozeFields($fields) |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @param Coollection $mledoze |
85 | 85 | * @param Coollection $natural |
86 | - * @return array |
|
86 | + * @return Coollection[] |
|
87 | 87 | */ |
88 | 88 | public function findMledozeCountry($mledoze, $natural) |
89 | 89 | { |
@@ -35,7 +35,7 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | /** |
94 | 94 | * Updater constructor. |
95 | - * @param object $config |
|
95 | + * @param ConfigService $config |
|
96 | 96 | * @param Helper $helper |
97 | 97 | */ |
98 | 98 | public function __construct($config, Helper $helper) |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
134 | - * @return mixed |
|
134 | + * @return Command |
|
135 | 135 | */ |
136 | 136 | public function getCommand() |
137 | 137 | { |
@@ -219,8 +219,8 @@ discard block |
||
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
222 | - * @param $result |
|
223 | - * @param $type |
|
222 | + * @param Coollection $result |
|
223 | + * @param string $type |
|
224 | 224 | * @return \PragmaRX\Coollection\Package\Coollection |
225 | 225 | */ |
226 | 226 | public function addRecordType($result, $type) |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @param \PragmaRX\Coollection\Package\Coollection $on |
260 | 260 | * @param \PragmaRX\Coollection\Package\Coollection $by |
261 | 261 | * @param $fields |
262 | - * @param $codeField |
|
262 | + * @param string $codeField |
|
263 | 263 | * @return array |
264 | 264 | */ |
265 | 265 | public function findByFields($on, $by, $fields, $codeField) |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | /** |
342 | 342 | * @param $result |
343 | 343 | * @param $dir |
344 | - * @param $normalizerClosure |
|
344 | + * @param Closure $normalizerClosure |
|
345 | 345 | * @return array |
346 | 346 | */ |
347 | 347 | public function normalizeData($result, $dir, $normalizerClosure) |
@@ -209,7 +209,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -3,12 +3,12 @@ |
||
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; |
8 | 7 | use PragmaRX\Countries\Package\Contracts\Config; |
9 | -use PragmaRX\Countries\Package\Services\Command; |
|
10 | 8 | use PragmaRX\Countries\Package\Services\Cache\Service as Cache; |
9 | +use PragmaRX\Countries\Package\Services\Command; |
|
11 | 10 | use PragmaRX\Countries\Package\Services\Config as ConfigService; |
11 | +use PragmaRX\Countries\Package\Support\Base; |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * @codeCoverageIgnore |
@@ -48,7 +48,7 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | /** |
70 | 70 | * Add suffix to string. |
71 | 71 | * |
72 | - * @param $suffix |
|
73 | - * @param $string |
|
74 | - * @return mixed |
|
72 | + * @param string string |
|
73 | + * @param string $string |
|
74 | + * @return string |
|
75 | 75 | */ |
76 | 76 | protected function addSuffix($suffix, $string) |
77 | 77 | { |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * Delete a whole directory. |
100 | 100 | * |
101 | - * @param $dir |
|
101 | + * @param string $dir |
|
102 | 102 | */ |
103 | 103 | protected function deleteDirectory($dir) |
104 | 104 | { |
@@ -116,6 +116,11 @@ discard block |
||
116 | 116 | rmdir($dir); |
117 | 117 | } |
118 | 118 | |
119 | + /** |
|
120 | + * @param string $string |
|
121 | + * |
|
122 | + * @return resource |
|
123 | + */ |
|
119 | 124 | protected function fopenOrFail($url, $string) |
120 | 125 | { |
121 | 126 | if (($handle = @fopen($url, $string)) === false) { |
@@ -184,7 +189,7 @@ discard block |
||
184 | 189 | |
185 | 190 | /** |
186 | 191 | * @param $url |
187 | - * @param $destination |
|
192 | + * @param string $destination |
|
188 | 193 | */ |
189 | 194 | public function downloadFile($url, $destination) |
190 | 195 | { |
@@ -255,8 +260,8 @@ discard block |
||
255 | 260 | /** |
256 | 261 | * @param $file |
257 | 262 | * @param $subPath |
258 | - * @param $path |
|
259 | - * @param $exclude |
|
263 | + * @param string $path |
|
264 | + * @param string $exclude |
|
260 | 265 | */ |
261 | 266 | protected function renameMasterToPackage($file, $subPath, $path, $exclude) |
262 | 267 | { |
@@ -310,7 +315,7 @@ discard block |
||
310 | 315 | /** |
311 | 316 | * Load a shapeFile. |
312 | 317 | * |
313 | - * @param $dir |
|
318 | + * @param string $dir |
|
314 | 319 | * @return \PragmaRX\Coollection\Package\Coollection |
315 | 320 | */ |
316 | 321 | public function shapeFile($dir) |
@@ -391,7 +396,7 @@ discard block |
||
391 | 396 | * Unzip a file. |
392 | 397 | * |
393 | 398 | * @param $file |
394 | - * @param $path |
|
399 | + * @param string $path |
|
395 | 400 | */ |
396 | 401 | public function unzip($file, $path) |
397 | 402 | { |
@@ -483,7 +488,7 @@ discard block |
||
483 | 488 | /** |
484 | 489 | * Load json files from dir. |
485 | 490 | * |
486 | - * @param $dir |
|
491 | + * @param string $dir |
|
487 | 492 | * @return \PragmaRX\Coollection\Package\Coollection |
488 | 493 | */ |
489 | 494 | public function loadJsonFiles($dir) |
@@ -569,7 +574,7 @@ discard block |
||
569 | 574 | /** |
570 | 575 | * Loads a json file. |
571 | 576 | * |
572 | - * @param $file |
|
577 | + * @param string $file |
|
573 | 578 | * @param string $dir |
574 | 579 | * @return \PragmaRX\Coollection\Package\Coollection |
575 | 580 | * @throws \Exception |
@@ -606,7 +611,7 @@ discard block |
||
606 | 611 | /** |
607 | 612 | * Put contents into a file. |
608 | 613 | * |
609 | - * @param $file |
|
614 | + * @param string $file |
|
610 | 615 | * @param $contents |
611 | 616 | */ |
612 | 617 | public function putFile($file, $contents) |
@@ -3,13 +3,13 @@ |
||
3 | 3 | namespace PragmaRX\Countries\Update; |
4 | 4 | |
5 | 5 | use Exception; |
6 | -use ReflectionClass; |
|
7 | -use ShapeFile\ShapeFile; |
|
8 | -use RecursiveIteratorIterator; |
|
9 | -use RecursiveDirectoryIterator; |
|
10 | 6 | use IlluminateAgnostic\Str\Support\Str; |
11 | 7 | use PragmaRX\Countries\Package\Services\Command; |
12 | 8 | use PragmaRX\Countries\Package\Services\Helper as ServiceHelper; |
9 | +use RecursiveDirectoryIterator; |
|
10 | +use RecursiveIteratorIterator; |
|
11 | +use ReflectionClass; |
|
12 | +use ShapeFile\ShapeFile; |
|
13 | 13 | |
14 | 14 | class Helper |
15 | 15 | { |
@@ -159,7 +159,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
262 | 262 | protected function renameMasterToPackage($file, $subPath, $path, $exclude) |
263 | 263 | { |
264 | 264 | if (Str::endsWith($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 |
||
278 | 278 | { |
279 | 279 | $path = dirname($file); |
280 | 280 | |
281 | - if (! Str::endsWith($file, '.zip') || file_exists($subPath = "$path/$subPath")) { |
|
281 | + if (!Str::endsWith($file, '.zip') || file_exists($subPath = "$path/$subPath")) { |
|
282 | 282 | return; |
283 | 283 | } |
284 | 284 | |
@@ -297,7 +297,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | */ |
492 | 492 | public function loadJsonFiles($dir) |
493 | 493 | { |
494 | - return coollect(glob("$dir/*.json*"))->mapWithKeys(function ($file) { |
|
494 | + return coollect(glob("$dir/*.json*"))->mapWithKeys(function($file) { |
|
495 | 495 | $key = str_replace('.json', '', str_replace('.json5', '', basename($file))); |
496 | 496 | |
497 | 497 | return [$key => $this->loadJson($file)]; |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | */ |
525 | 525 | public function moveDataFiles() |
526 | 526 | { |
527 | - $this->config->get('moveable')->each(function ($to, $from) { |
|
527 | + $this->config->get('moveable')->each(function($to, $from) { |
|
528 | 528 | $this->moveDataFile($from, $to); |
529 | 529 | }); |
530 | 530 | } |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | */ |
554 | 554 | public function message($message, $type = 'line') |
555 | 555 | { |
556 | - if (! is_null($this->command)) { |
|
556 | + if (!is_null($this->command)) { |
|
557 | 557 | $this->command->{$type}($message); |
558 | 558 | } |
559 | 559 | } |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | $this->abort('loadCsv Error: File name not set'); |
584 | 584 | } |
585 | 585 | |
586 | - if (! file_exists($file)) { |
|
586 | + if (!file_exists($file)) { |
|
587 | 587 | $file = $this->dataDir($this->addSuffix('.csv', "/$dir/".strtolower($file))); |
588 | 588 | } |
589 | 589 | |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | */ |
600 | 600 | public function makeJsonFileName($key, $dir = '') |
601 | 601 | { |
602 | - if (! Str::endsWith($dir, (DIRECTORY_SEPARATOR))) { |
|
602 | + if (!Str::endsWith($dir, (DIRECTORY_SEPARATOR))) { |
|
603 | 603 | $dir .= DIRECTORY_SEPARATOR; |
604 | 604 | } |
605 | 605 | |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | { |
681 | 681 | $this->progress('--- Delete temporary files'); |
682 | 682 | |
683 | - $this->config->get('deletable')->each(function ($directory) { |
|
683 | + $this->config->get('deletable')->each(function($directory) { |
|
684 | 684 | if (file_exists($directory = $this->dataDir($directory))) { |
685 | 685 | $this->deleteDirectory($directory); |
686 | 686 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | /** |
72 | 72 | * Check if cache is enabled. |
73 | 73 | * |
74 | - * @return bool |
|
74 | + * @return \PragmaRX\Coollection\Package\Coollection |
|
75 | 75 | */ |
76 | 76 | protected function enabled() |
77 | 77 | { |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * Delete an item from the cache by its unique key. |
133 | 133 | * |
134 | 134 | * @param string $key |
135 | - * @return bool |
|
135 | + * @return boolean|null |
|
136 | 136 | */ |
137 | 137 | public function delete($key) |
138 | 138 | { |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * Get an item from the cache, or store the default value. |
198 | 198 | * |
199 | 199 | * @param string $key |
200 | - * @param \DateTimeInterface|\DateInterval|float|int $minutes |
|
200 | + * @param integer $minutes |
|
201 | 201 | * @param Closure $callback |
202 | 202 | * @return mixed |
203 | 203 | */ |
@@ -3,9 +3,9 @@ |
||
3 | 3 | namespace PragmaRX\Countries\Package\Services\Cache; |
4 | 4 | |
5 | 5 | use Closure; |
6 | -use Psr\SimpleCache\CacheInterface; |
|
7 | -use PragmaRX\Countries\Package\Services\Config; |
|
8 | 6 | use PragmaRX\Countries\Package\Services\Cache\Managers\Nette as NetteManager; |
7 | +use PragmaRX\Countries\Package\Services\Config; |
|
8 | +use Psr\SimpleCache\CacheInterface; |
|
9 | 9 | |
10 | 10 | class Service implements CacheInterface |
11 | 11 | { |
@@ -202,7 +202,7 @@ |
||
202 | 202 | */ |
203 | 203 | public function remember($key, $minutes, Closure $callback) |
204 | 204 | { |
205 | - if (! \is_null($value = $this->manager->get($key))) { |
|
205 | + if (!\is_null($value = $this->manager->get($key))) { |
|
206 | 206 | return $value; |
207 | 207 | } |
208 | 208 |