@@ -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 | * |
@@ -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 | |
@@ -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 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | private function arrayFinder(string $propertyName, $find, Closure $finderClosure) |
| 110 | 110 | { |
| 111 | - return $this->filter(function ($data) use ($find, $propertyName, $finderClosure) { |
|
| 111 | + return $this->filter(function($data) use ($find, $propertyName, $finderClosure) { |
|
| 112 | 112 | try { |
| 113 | 113 | $attributeValue = $data->{$propertyName}; |
| 114 | 114 | } catch (\Exception $e) { |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | private function _whereKey(string $arrayName, $value) |
| 132 | 132 | { |
| 133 | - $finderClosure = function ($value, $attributeValue) { |
|
| 133 | + $finderClosure = function($value, $attributeValue) { |
|
| 134 | 134 | return Arr::has($attributeValue, $value); |
| 135 | 135 | }; |
| 136 | 136 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | private function _whereAttribute(string $arrayName, $value) |
| 150 | 150 | { |
| 151 | - $finderClosure = function ($value, $attributeValue) { |
|
| 151 | + $finderClosure = function($value, $attributeValue) { |
|
| 152 | 152 | return \in_array($value, $attributeValue->toArray()); |
| 153 | 153 | }; |
| 154 | 154 | |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | { |
| 7 | 7 | public function defineConstants() |
| 8 | 8 | { |
| 9 | - if (! \defined('__COUNTRIES_DIR__')) { |
|
| 9 | + if (!\defined('__COUNTRIES_DIR__')) { |
|
| 10 | 10 | \define( |
| 11 | 11 | '__COUNTRIES_DIR__', |
| 12 | 12 | realpath( |
@@ -48,7 +48,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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)); |
@@ -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 | } |