@@ -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 | |
@@ -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): void |
| 263 | 263 | { |
| 264 | 264 | if (ends_with($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 (! ends_with($file, '.zip') || file_exists($subPath = "$path/$subPath")) { |
|
| 281 | + if (!ends_with($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); |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | */ |
| 486 | 486 | public function loadJsonFiles($dir) |
| 487 | 487 | { |
| 488 | - return coollect(glob("$dir/*.json*"))->mapWithKeys(function ($file) { |
|
| 488 | + return coollect(glob("$dir/*.json*"))->mapWithKeys(function($file) { |
|
| 489 | 489 | $key = str_replace('.json', '', str_replace('.json5', '', basename($file))); |
| 490 | 490 | |
| 491 | 491 | return [$key => $this->loadJson($file)]; |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | */ |
| 519 | 519 | public function moveDataFiles() |
| 520 | 520 | { |
| 521 | - $this->config->get('moveable')->each(function ($to, $from) { |
|
| 521 | + $this->config->get('moveable')->each(function($to, $from) { |
|
| 522 | 522 | $this->moveDataFile($from, $to); |
| 523 | 523 | }); |
| 524 | 524 | } |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | */ |
| 548 | 548 | public function message($message, $type = 'line') |
| 549 | 549 | { |
| 550 | - if (! is_null($this->command)) { |
|
| 550 | + if (!is_null($this->command)) { |
|
| 551 | 551 | $this->command->{$type}($message); |
| 552 | 552 | } |
| 553 | 553 | } |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | $this->abort('loadCsv Error: File name not set'); |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - if (! file_exists($file)) { |
|
| 580 | + if (!file_exists($file)) { |
|
| 581 | 581 | $file = $this->dataDir($this->addSuffix('.csv', "/$dir/".strtolower($file))); |
| 582 | 582 | } |
| 583 | 583 | |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | */ |
| 594 | 594 | public function makeJsonFileName($key, $dir = '') |
| 595 | 595 | { |
| 596 | - if (! ends_with($dir, (DIRECTORY_SEPARATOR))) { |
|
| 596 | + if (!ends_with($dir, (DIRECTORY_SEPARATOR))) { |
|
| 597 | 597 | $dir .= DIRECTORY_SEPARATOR; |
| 598 | 598 | } |
| 599 | 599 | |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | { |
| 675 | 675 | $this->progress('--- Delete temporary files'); |
| 676 | 676 | |
| 677 | - $this->config->get('deletable')->each(function ($directory) { |
|
| 677 | + $this->config->get('deletable')->each(function($directory) { |
|
| 678 | 678 | if (file_exists($directory = $this->dataDir($directory))) { |
| 679 | 679 | $this->deleteDirectory($directory); |
| 680 | 680 | } |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | /** |
| 71 | 71 | * Add suffix to string. |
| 72 | 72 | * |
| 73 | - * @param $suffix |
|
| 74 | - * @param $string |
|
| 75 | - * @return mixed |
|
| 73 | + * @param string string |
|
| 74 | + * @param string $string |
|
| 75 | + * @return string |
|
| 76 | 76 | */ |
| 77 | 77 | protected function addSuffix($suffix, $string) |
| 78 | 78 | { |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | /** |
| 100 | 100 | * Delete a whole directory. |
| 101 | 101 | * |
| 102 | - * @param $dir |
|
| 102 | + * @param string $dir |
|
| 103 | 103 | */ |
| 104 | 104 | protected function deleteDirectory($dir) |
| 105 | 105 | { |
@@ -117,6 +117,11 @@ discard block |
||
| 117 | 117 | rmdir($dir); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | + /** |
|
| 121 | + * @param string $string |
|
| 122 | + * |
|
| 123 | + * @return resource |
|
| 124 | + */ |
|
| 120 | 125 | protected function fopenOrFail($url, $string) |
| 121 | 126 | { |
| 122 | 127 | if (($handle = @fopen($url, $string)) === false) { |
@@ -185,7 +190,7 @@ discard block |
||
| 185 | 190 | |
| 186 | 191 | /** |
| 187 | 192 | * @param $url |
| 188 | - * @param $destination |
|
| 193 | + * @param string $destination |
|
| 189 | 194 | */ |
| 190 | 195 | public function downloadFile($url, $destination) |
| 191 | 196 | { |
@@ -256,8 +261,8 @@ discard block |
||
| 256 | 261 | /** |
| 257 | 262 | * @param $file |
| 258 | 263 | * @param $subPath |
| 259 | - * @param $path |
|
| 260 | - * @param $exclude |
|
| 264 | + * @param string $path |
|
| 265 | + * @param string $exclude |
|
| 261 | 266 | */ |
| 262 | 267 | protected function renameMasterToPackage($file, $subPath, $path, $exclude): void |
| 263 | 268 | { |
@@ -311,8 +316,8 @@ discard block |
||
| 311 | 316 | /** |
| 312 | 317 | * Load a shapeFile. |
| 313 | 318 | * |
| 314 | - * @param $dir |
|
| 315 | - * @return \PragmaRX\Coollection\Package\Coollection |
|
| 319 | + * @param string $dir |
|
| 320 | + * @return string |
|
| 316 | 321 | */ |
| 317 | 322 | public function shapeFile($dir) |
| 318 | 323 | { |
@@ -392,7 +397,7 @@ discard block |
||
| 392 | 397 | * Unzip a file. |
| 393 | 398 | * |
| 394 | 399 | * @param $file |
| 395 | - * @param $path |
|
| 400 | + * @param string $path |
|
| 396 | 401 | */ |
| 397 | 402 | public function unzip($file, $path) |
| 398 | 403 | { |
@@ -480,7 +485,7 @@ discard block |
||
| 480 | 485 | /** |
| 481 | 486 | * Load json files from dir. |
| 482 | 487 | * |
| 483 | - * @param $dir |
|
| 488 | + * @param string $dir |
|
| 484 | 489 | * @return \PragmaRX\Coollection\Package\Coollection |
| 485 | 490 | */ |
| 486 | 491 | public function loadJsonFiles($dir) |
@@ -566,7 +571,7 @@ discard block |
||
| 566 | 571 | /** |
| 567 | 572 | * Loads a json file. |
| 568 | 573 | * |
| 569 | - * @param $file |
|
| 574 | + * @param string $file |
|
| 570 | 575 | * @param string $dir |
| 571 | 576 | * @return \PragmaRX\Coollection\Package\Coollection |
| 572 | 577 | * @throws \Exception |
@@ -603,7 +608,7 @@ discard block |
||
| 603 | 608 | /** |
| 604 | 609 | * Put contents into a file. |
| 605 | 610 | * |
| 606 | - * @param $file |
|
| 611 | + * @param string $file |
|
| 607 | 612 | * @param $contents |
| 608 | 613 | */ |
| 609 | 614 | 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; |
|
| 6 | +use PragmaRX\Countries\Package\Contracts\Config as ConfigContract; |
|
| 10 | 7 | use PragmaRX\Countries\Package\Services\Command; |
| 11 | 8 | use PragmaRX\Countries\Package\Services\Helper as ServiceHelper; |
| 12 | -use PragmaRX\Countries\Package\Contracts\Config as ConfigContract; |
|
| 9 | +use RecursiveDirectoryIterator; |
|
| 10 | +use RecursiveIteratorIterator; |
|
| 11 | +use ReflectionClass; |
|
| 12 | +use ShapeFile\ShapeFile; |
|
| 13 | 13 | |
| 14 | 14 | class Helper |
| 15 | 15 | { |
@@ -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 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | { |
| 109 | 109 | $this->countriesJson = $this->loadCountriesJson(); |
| 110 | 110 | |
| 111 | - $overload = $this->helper->loadJsonFiles($this->helper->dataDir('countries/overload'))->mapWithKeys(function ($country, $code) { |
|
| 111 | + $overload = $this->helper->loadJsonFiles($this->helper->dataDir('countries/overload'))->mapWithKeys(function($country, $code) { |
|
| 112 | 112 | return [upper($code) => $country]; |
| 113 | 113 | }); |
| 114 | 114 | |
@@ -161,11 +161,11 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function currencies() |
| 163 | 163 | { |
| 164 | - $currencies = $this->helper->loadJsonFiles($this->helper->dataDir('currencies/default'))->mapWithKeys(function ($country, $code) { |
|
| 164 | + $currencies = $this->helper->loadJsonFiles($this->helper->dataDir('currencies/default'))->mapWithKeys(function($country, $code) { |
|
| 165 | 165 | return [upper($code) => $country]; |
| 166 | 166 | }); |
| 167 | 167 | |
| 168 | - $overload = $this->helper->loadJsonFiles($this->helper->dataDir('currencies/overload'))->mapWithKeys(function ($country, $code) { |
|
| 168 | + $overload = $this->helper->loadJsonFiles($this->helper->dataDir('currencies/overload'))->mapWithKeys(function($country, $code) { |
|
| 169 | 169 | return [upper($code) => $country]; |
| 170 | 170 | }); |
| 171 | 171 | |
@@ -59,10 +59,10 @@ |
||
| 59 | 59 | /** |
| 60 | 60 | * Repository constructor. |
| 61 | 61 | * |
| 62 | - * @param CacheContract $cache |
|
| 62 | + * @param Cache $cache |
|
| 63 | 63 | * @param Hydrator $hydrator |
| 64 | 64 | * @param Helper $helper |
| 65 | - * @param object $config |
|
| 65 | + * @param \PragmaRX\Countries\Package\Services\Config $config |
|
| 66 | 66 | */ |
| 67 | 67 | public function __construct(CacheContract $cache, Hydrator $hydrator, Helper $helper, $config) |
| 68 | 68 | { |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | throw new Exception('loadJson Error: File name not set'); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - if (! file_exists($file) && ! file_exists($file = $this->dataDir("/$dir/".strtolower($file).'.json'))) { |
|
| 52 | + if (!file_exists($file) && !file_exists($file = $this->dataDir("/$dir/".strtolower($file).'.json'))) { |
|
| 53 | 53 | return coollect(); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function loadJsonFiles($dir) |
| 72 | 72 | { |
| 73 | - return coollect(glob("$dir/*.json*"))->mapWithKeys(function ($file) { |
|
| 73 | + return coollect(glob("$dir/*.json*"))->mapWithKeys(function($file) { |
|
| 74 | 74 | $key = str_replace('.json', '', str_replace('.json5', '', basename($file))); |
| 75 | 75 | |
| 76 | 76 | return [$key => $this->loadJson($file)]; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function moveFilesWildcard($from, $to) |
| 87 | 87 | { |
| 88 | - coollect(glob($this->dataDir($from)))->each(function ($from) use ($to) { |
|
| 88 | + coollect(glob($this->dataDir($from)))->each(function($from) use ($to) { |
|
| 89 | 89 | $this->mkDir($dir = $this->dataDir($to)); |
| 90 | 90 | |
| 91 | 91 | rename($from, $dir.'/'.basename($from)); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | /** |
| 65 | 65 | * Load json files from dir. |
| 66 | 66 | * |
| 67 | - * @param $dir |
|
| 67 | + * @param string $dir |
|
| 68 | 68 | * @return \PragmaRX\Coollection\Package\Coollection |
| 69 | 69 | */ |
| 70 | 70 | public function loadJsonFiles($dir) |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | - * @param $contents |
|
| 108 | + * @param string $contents |
|
| 109 | 109 | * @return string |
| 110 | 110 | */ |
| 111 | 111 | public function sanitizeFile($contents) |
@@ -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( |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * Delete an item from the cache by its unique key. |
| 120 | 120 | * |
| 121 | 121 | * @param string $key |
| 122 | - * @return bool |
|
| 122 | + * @return boolean|null |
|
| 123 | 123 | */ |
| 124 | 124 | public function delete($key) |
| 125 | 125 | { |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * Get an item from the cache, or store the default value. |
| 208 | 208 | * |
| 209 | 209 | * @param string $key |
| 210 | - * @param \DateTimeInterface|\DateInterval|float|int $minutes |
|
| 210 | + * @param integer $minutes |
|
| 211 | 211 | * @param Closure $callback |
| 212 | 212 | * @return mixed |
| 213 | 213 | */ |
@@ -3,8 +3,8 @@ |
||
| 3 | 3 | namespace PragmaRX\Countries\Package\Services; |
| 4 | 4 | |
| 5 | 5 | use Closure; |
| 6 | -use Psr\SimpleCache\CacheInterface; |
|
| 7 | 6 | use PragmaRX\Countries\Package\Services\Cache\Managers\Nette as NetteManager; |
| 7 | +use Psr\SimpleCache\CacheInterface; |
|
| 8 | 8 | |
| 9 | 9 | class Cache implements CacheInterface |
| 10 | 10 | { |
@@ -203,7 +203,7 @@ |
||
| 203 | 203 | */ |
| 204 | 204 | public function remember($key, $minutes, Closure $callback) |
| 205 | 205 | { |
| 206 | - if (! is_null($value = $this->manager->get($key))) { |
|
| 206 | + if (!is_null($value = $this->manager->get($key))) { |
|
| 207 | 207 | return $value; |
| 208 | 208 | } |
| 209 | 209 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | - * @return mixed |
|
| 128 | + * @return Command |
|
| 129 | 129 | */ |
| 130 | 130 | public function getCommand() |
| 131 | 131 | { |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | /** |
| 207 | 207 | * @param $result |
| 208 | - * @param $type |
|
| 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 |
||
| 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 |
||
| 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) |
@@ -3,13 +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; |
| 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 |
@@ -194,7 +194,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | if (is_null($this->dir)) { |
| 56 | 56 | $this->dir = $this->config->cache->directory ?: sys_get_temp_dir().'/__PRAGMARX_COUNTRIES__/cache'; |
| 57 | 57 | |
| 58 | - if (! file_exists($this->dir)) { |
|
| 58 | + if (!file_exists($this->dir)) { |
|
| 59 | 59 | mkdir($this->dir, 0755, true); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | public function getMultiple($keys, $default = null) |
| 145 | 145 | { |
| 146 | - return coollect($keys)->map(function ($key) { |
|
| 146 | + return coollect($keys)->map(function($key) { |
|
| 147 | 147 | return $this->get($key); |
| 148 | 148 | }); |
| 149 | 149 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | public function setMultiple($values, $ttl = null) |
| 159 | 159 | { |
| 160 | - return coollect($values)->map(function ($value, $key) use ($ttl) { |
|
| 160 | + return coollect($values)->map(function($value, $key) use ($ttl) { |
|
| 161 | 161 | return $this->set($key, $value, $ttl); |
| 162 | 162 | }); |
| 163 | 163 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function deleteMultiple($keys) |
| 172 | 172 | { |
| 173 | - coollect($keys)->map(function ($key) { |
|
| 173 | + coollect($keys)->map(function($key) { |
|
| 174 | 174 | $this->forget($key); |
| 175 | 175 | }); |
| 176 | 176 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | public function has($key) |
| 185 | 185 | { |
| 186 | - return ! is_null($this->get($key)); |
|
| 186 | + return !is_null($this->get($key)); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | { |
| 216 | 216 | $value = $this->get($key); |
| 217 | 217 | |
| 218 | - if (! is_null($value)) { |
|
| 218 | + if (!is_null($value)) { |
|
| 219 | 219 | return $value; |
| 220 | 220 | } |
| 221 | 221 | |
@@ -134,7 +134,7 @@ |
||
| 134 | 134 | * Delete an item from the cache by its unique key. |
| 135 | 135 | * |
| 136 | 136 | * @param string $key |
| 137 | - * @return bool |
|
| 137 | + * @return boolean|null |
|
| 138 | 138 | */ |
| 139 | 139 | public function delete($key) |
| 140 | 140 | { |
@@ -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 | { |