@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | $depth = 0; |
| 14 | 14 | |
| 15 | - while (! file_exists($dir.DIRECTORY_SEPARATOR.'composer.json') && $depth < 16) { |
|
| 15 | + while (!file_exists($dir.DIRECTORY_SEPARATOR.'composer.json') && $depth < 16) { |
|
| 16 | 16 | $dir .= DIRECTORY_SEPARATOR.'..'; |
| 17 | 17 | |
| 18 | 18 | $depth++; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | function array_is_multidimensional($item) |
| 44 | 44 | { |
| 45 | - if (! is_array($item)) { |
|
| 45 | + if (!is_array($item)) { |
|
| 46 | 46 | return false; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -93,9 +93,9 @@ |
||
| 93 | 93 | { |
| 94 | 94 | $result = $this->generateExportData($this->readSourceFile()); |
| 95 | 95 | |
| 96 | - collect($result)->map(function ($item) { |
|
| 96 | + collect($result)->map(function($item) { |
|
| 97 | 97 | return $this->normalize($item); |
| 98 | - })->groupBy('grouping')->each(function ($item, $key) { |
|
| 98 | + })->groupBy('grouping')->each(function($item, $key) { |
|
| 99 | 99 | file_put_contents($this->makeStateFileName($key), json_encode($item)); |
| 100 | 100 | }); |
| 101 | 101 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | protected function canHydrate($element, $enabled, $countryCode) |
| 25 | 25 | { |
| 26 | 26 | return ($enabled || config('countries.hydrate.elements.'.$element)) && |
| 27 | - ! isset($this->repository->countries[$countryCode]['hydrated'][$element]); |
|
| 27 | + !isset($this->repository->countries[$countryCode]['hydrated'][$element]); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | protected function createHydrated($countryCode) |
| 45 | 45 | { |
| 46 | - if (! isset($this->repository->countries[$countryCode]['hydrated'])) { |
|
| 46 | + if (!isset($this->repository->countries[$countryCode]['hydrated'])) { |
|
| 47 | 47 | $this->repository->countries[$countryCode]['hydrated'] = []; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | protected function needsHydration($countryCode, $element, $enabled = false) |
| 62 | 62 | { |
| 63 | - if (! $this->canHydrate($element, $enabled, $countryCode)) { |
|
| 63 | + if (!$this->canHydrate($element, $enabled, $countryCode)) { |
|
| 64 | 64 | return false; |
| 65 | 65 | } |
| 66 | 66 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | protected function getHydrationElements($elements) |
| 127 | 127 | { |
| 128 | - if (! is_array($elements = $elements ?: config('countries.hydrate.elements'))) { |
|
| 128 | + if (!is_array($elements = $elements ?: config('countries.hydrate.elements'))) { |
|
| 129 | 129 | return [$elements => true]; |
| 130 | 130 | } |
| 131 | 131 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | protected function hydrateBorders($country) |
| 155 | 155 | { |
| 156 | - $country['borders'] = collect($country['borders'])->map(function ($border) { |
|
| 156 | + $country['borders'] = collect($country['borders'])->map(function($border) { |
|
| 157 | 157 | $border = $this->repository->call('where', ['cca3', $border]); |
| 158 | 158 | |
| 159 | 159 | if ($border instanceof Collection && $border->count() == 1) { |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | protected function hydrateTimezone($country) |
| 176 | 176 | { |
| 177 | - if (! isset($this->repository->timezones[$country['cca2']])) { |
|
| 177 | + if (!isset($this->repository->timezones[$country['cca2']])) { |
|
| 178 | 178 | return $country; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | protected function hydrateCurrency($country) |
| 193 | 193 | { |
| 194 | - $country['currency'] = collect($country['currency'])->map(function ($code) { |
|
| 194 | + $country['currency'] = collect($country['currency'])->map(function($code) { |
|
| 195 | 195 | return $this->repository->currenciesRepository->loadCurrency($code); |
| 196 | 196 | }); |
| 197 | 197 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | $elements = $this->getHydrationElements($elements); |
| 211 | 211 | |
| 212 | 212 | return $this->repository->collection( |
| 213 | - $countries->map(function ($country) use ($elements) { |
|
| 213 | + $countries->map(function($country) use ($elements) { |
|
| 214 | 214 | $country = $this->toArray($country); |
| 215 | 215 | |
| 216 | 216 | $countryCode = $country['cca3']; |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | public function addCountry($countryCode, $country) |
| 247 | 247 | { |
| 248 | - if (! isset($this->repository->countries[$countryCode])) { |
|
| 248 | + if (!isset($this->repository->countries[$countryCode])) { |
|
| 249 | 249 | $this->repository->countries[$countryCode] = $country; |
| 250 | 250 | } |
| 251 | 251 | } |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | protected function checkHydrationElements($elements) |
| 274 | 274 | { |
| 275 | - $elements = collect($elements)->mapWithKeys(function ($value, $key) { |
|
| 275 | + $elements = collect($elements)->mapWithKeys(function($value, $key) { |
|
| 276 | 276 | if (is_numeric($key)) { |
| 277 | 277 | $key = $value; |
| 278 | 278 | $value = true; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @param callable|null $callback |
| 27 | 27 | * @param null $default |
| 28 | - * @return mixed|Collection |
|
| 28 | + * @return Collection |
|
| 29 | 29 | */ |
| 30 | 30 | public function first(callable $callback = null, $default = null) |
| 31 | 31 | { |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | /** |
| 36 | 36 | * Get and remove the last item from the collection. |
| 37 | 37 | * |
| 38 | - * @return mixed |
|
| 38 | + * @return Collection |
|
| 39 | 39 | */ |
| 40 | 40 | public function pop() |
| 41 | 41 | { |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | /** |
| 58 | 58 | * Get and remove the first item from the collection. |
| 59 | 59 | * |
| 60 | - * @return mixed |
|
| 60 | + * @return Collection |
|
| 61 | 61 | */ |
| 62 | 62 | public function shift() |
| 63 | 63 | { |
@@ -117,6 +117,9 @@ discard block |
||
| 117 | 117 | return parent::__call($name, $arguments); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | + /** |
|
| 121 | + * @param string $key |
|
| 122 | + */ |
|
| 120 | 123 | public function where($key, $operator, $value = null) |
| 121 | 124 | { |
| 122 | 125 | if (func_num_args() == 2) { |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | private function createMacros() |
| 71 | 71 | { |
| 72 | - static::macro('hydrate', function ($elements) { |
|
| 72 | + static::macro('hydrate', function($elements) { |
|
| 73 | 73 | return CountriesFacade::hydrate($this, $elements); |
| 74 | 74 | }); |
| 75 | 75 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | return $this->items[$key]; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if (! in_array($key, static::$proxies)) { |
|
| 99 | + if (!in_array($key, static::$proxies)) { |
|
| 100 | 100 | throw new Exception("Property [{$key}] does not exist on this collection instance."); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | private function _whereAttribute(string $arrayName, $value) |
| 154 | 154 | { |
| 155 | - return $this->filter(function ($data) use ($value, $arrayName) { |
|
| 155 | + return $this->filter(function($data) use ($value, $arrayName) { |
|
| 156 | 156 | if (isset($data->{$arrayName})) { |
| 157 | 157 | return in_array($value, (array) $data->{$arrayName}); |
| 158 | 158 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | private function _whereKey(string $arrayName, $value) |
| 165 | 165 | { |
| 166 | - return $this->filter(function ($data) use ($value, $arrayName) { |
|
| 166 | + return $this->filter(function($data) use ($value, $arrayName) { |
|
| 167 | 167 | if (isset($data->{$arrayName})) { |
| 168 | 168 | return Arr::has($data->{$arrayName}, $value); |
| 169 | 169 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | $hydrator = new Hydrator(); |
| 86 | 86 | |
| 87 | - $this->app->singleton('pragmarx.countries', function () use ($cache, $hydrator) { |
|
| 87 | + $this->app->singleton('pragmarx.countries', function() use ($cache, $hydrator) { |
|
| 88 | 88 | $repository = new CountriesRepository($cache, new CurrenciesRepository(), $hydrator); |
| 89 | 89 | |
| 90 | 90 | $hydrator->setRepository($repository); |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | if (is_int($ruleName)) { |
| 100 | 100 | $ruleName = $countryAttribute; |
| 101 | 101 | } |
| 102 | - Validator::extend($ruleName, function ($attribute, $value) use ($countryAttribute) { |
|
| 103 | - return ! Countries::where($countryAttribute, $value)->isEmpty(); |
|
| 102 | + Validator::extend($ruleName, function($attribute, $value) use ($countryAttribute) { |
|
| 103 | + return !Countries::where($countryAttribute, $value)->isEmpty(); |
|
| 104 | 104 | }, 'The :attribute must be a valid '.$ruleName.'.'); |
| 105 | 105 | } |
| 106 | 106 | } |