@@ -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 | |
@@ -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 | } |
@@ -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 | { |
@@ -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,7 +316,7 @@ discard block |
||
| 311 | 316 | /** |
| 312 | 317 | * Load a shapeFile. |
| 313 | 318 | * |
| 314 | - * @param $dir |
|
| 319 | + * @param string $dir |
|
| 315 | 320 | * @return \PragmaRX\Coollection\Package\Coollection |
| 316 | 321 | */ |
| 317 | 322 | public function shapeFile($dir) |
@@ -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) |
@@ -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 | |
@@ -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 | { |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use PragmaRX\Countries\Package\Services\Cache; |
| 6 | 6 | use PragmaRX\Countries\Package\Services\Helper; |
| 7 | -use PragmaRX\Countries\Package\Contracts\Config; |
|
| 8 | 7 | use PragmaRX\Countries\Package\Services\Hydrator; |
| 9 | 8 | use Psr\SimpleCache\CacheInterface as CacheContract; |
| 10 | 9 | |
@@ -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)); |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * Rinvex constructor. |
| 16 | 16 | * |
| 17 | - * @param object $config |
|
| 17 | + * @param Config $config |
|
| 18 | 18 | */ |
| 19 | 19 | public function __construct($config) |
| 20 | 20 | { |
@@ -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) |
@@ -2,8 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace PragmaRX\Countries\Package\Services; |
| 4 | 4 | |
| 5 | -use PragmaRX\Countries\Package\Contracts\Config; |
|
| 6 | - |
|
| 7 | 5 | class Helper |
| 8 | 6 | { |
| 9 | 7 | /** |
@@ -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( |
@@ -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,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 | |
@@ -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,11 +3,10 @@ |
||
| 3 | 3 | namespace PragmaRX\Countries\Package\Services\Cache\Managers; |
| 4 | 4 | |
| 5 | 5 | use Closure; |
| 6 | -use Exception; |
|
| 7 | -use Psr\SimpleCache\CacheInterface; |
|
| 8 | 6 | use Nette\Caching\Cache as NetteCache; |
| 9 | 7 | use Nette\Caching\Storages\FileStorage; |
| 10 | 8 | use PragmaRX\Countries\Package\Services\Config; |
| 9 | +use Psr\SimpleCache\CacheInterface; |
|
| 11 | 10 | |
| 12 | 11 | class Nette implements CacheInterface |
| 13 | 12 | { |
@@ -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 | |