Completed
Pull Request — master (#16)
by Andrea
04:25
created
src/Support/helpers.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Support/ExportData.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -93,9 +93,9 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Support/Hydrator.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Support/Collection.php 2 patches
Doc Comments   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
src/ServiceProvider.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.