Completed
Pull Request — master (#409)
by
unknown
40s
created
src/Traits/Buildable.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 {
10 10
     public function avg($column)
11 11
     {
12
-        if (! $this->isCachable()) {
12
+        if (!$this->isCachable()) {
13 13
             return parent::avg($column);
14 14
         }
15 15
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
     public function count($columns = "*")
22 22
     {
23
-        if (! $this->isCachable()) {
23
+        if (!$this->isCachable()) {
24 24
             return parent::count($columns);
25 25
         }
26 26
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
     public function exists()
33 33
     {
34
-        if (! $this->isCachable()) {
34
+        if (!$this->isCachable()) {
35 35
             return parent::exists();
36 36
         }
37 37
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function find($id, $columns = ["*"])
63 63
     {
64
-        if (! $this->isCachable()) {
64
+        if (!$this->isCachable()) {
65 65
             return parent::find($id, $columns);
66 66
         }
67 67
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
     public function first($columns = ["*"])
80 80
     {
81
-        if (! $this->isCachable()) {
81
+        if (!$this->isCachable()) {
82 82
             return parent::first($columns);
83 83
         }
84 84
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
     public function get($columns = ["*"])
100 100
     {
101
-        if (! $this->isCachable()) {
101
+        if (!$this->isCachable()) {
102 102
             return parent::get($columns);
103 103
         }
104 104
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
     public function max($column)
136 136
     {
137
-        if (! $this->isCachable()) {
137
+        if (!$this->isCachable()) {
138 138
             return parent::max($column);
139 139
         }
140 140
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
     public function min($column)
147 147
     {
148
-        if (! $this->isCachable()) {
148
+        if (!$this->isCachable()) {
149 149
             return parent::min($column);
150 150
         }
151 151
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         $pageName = "page",
161 161
         $page = null
162 162
     ) {
163
-        if (! $this->isCachable()) {
163
+        if (!$this->isCachable()) {
164 164
             return parent::paginate($perPage, $columns, $pageName, $page);
165 165
         }
166 166
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         $result = "";
185 185
 
186 186
         foreach ($items as $key => $value) {
187
-            $result .= $glue . $key . $glue . $value;
187
+            $result .= $glue.$key.$glue.$value;
188 188
         }
189 189
 
190 190
         return $result;
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 
193 193
     public function pluck($column, $key = null)
194 194
     {
195
-        if (! $this->isCachable()) {
195
+        if (!$this->isCachable()) {
196 196
             return parent::pluck($column, $key);
197 197
         }
198 198
 
199
-        $keyDifferentiator = "-pluck_{$column}" . ($key ? "_{$key}" : "");
199
+        $keyDifferentiator = "-pluck_{$column}".($key ? "_{$key}" : "");
200 200
         $cacheKey = $this->makeCacheKey([$column], null, $keyDifferentiator);
201 201
 
202 202
         return $this->cachedValue(func_get_args(), $cacheKey);
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
     public function sum($column)
206 206
     {
207
-        if (! $this->isCachable()) {
207
+        if (!$this->isCachable()) {
208 208
             return parent::sum($column);
209 209
         }
210 210
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
     public function value($column)
226 226
     {
227
-        if (! $this->isCachable()) {
227
+        if (!$this->isCachable()) {
228 228
             return parent::value($column);
229 229
         }
230 230
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
         return $this->cache($cacheTags)
300 300
             ->rememberForever(
301 301
                 $hashedCacheKey,
302
-                function () use ($arguments, $cacheKey, $method) {
302
+                function() use ($arguments, $cacheKey, $method) {
303 303
                     return [
304 304
                         "key" => $cacheKey,
305 305
                         "value" => parent::{$method}(...$arguments),
Please login to merge, or discard this patch.
tests/Integration/CachedBuilder/BooleanTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         factory(Book::class)->create(['author_id' => $expectedAuthor->getKey(), 'title' => 'Mixed Clause']);
68 68
 
69 69
         $books = (new Book)
70
-            ->whereHas('author', function ($query) {
70
+            ->whereHas('author', function($query) {
71 71
                 return $query->where('is_famous', false);
72 72
             })
73 73
             ->whereRaw("title = ?", ['Mixed Clause']) // Test ensures this binding is included in the key
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             ->tags($tags)
77 77
             ->get($key)['value'];
78 78
         $liveResults = (new UncachedBook)
79
-            ->whereHas('author', function ($query) {
79
+            ->whereHas('author', function($query) {
80 80
                 return $query->where('is_famous', false);
81 81
             })
82 82
             ->whereRaw("title = ?", ['Mixed Clause'])
Please login to merge, or discard this patch.
src/CacheKey.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 
59 59
     protected function getLimitClause() : string
60 60
     {
61
-        if (! property_exists($this->query, "limit")
62
-            || ! $this->query->limit
61
+        if (!property_exists($this->query, "limit")
62
+            || !$this->query->limit
63 63
         ) {
64 64
             return "";
65 65
         }
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 
81 81
     protected function getOffsetClause() : string
82 82
     {
83
-        if (! property_exists($this->query, "offset")
84
-            || ! $this->query->offset
83
+        if (!property_exists($this->query, "offset")
84
+            || !$this->query->offset
85 85
         ) {
86 86
             return "";
87 87
         }
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 
92 92
     protected function getOrderByClauses() : string
93 93
     {
94
-        if (! property_exists($this->query, "orders")
95
-            || ! $this->query->orders
94
+        if (!property_exists($this->query, "orders")
95
+            || !$this->query->orders
96 96
         ) {
97 97
             return "";
98 98
         }
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
         $orders = collect($this->query->orders);
101 101
 
102 102
         return $orders
103
-            ->reduce(function ($carry, $order) {
103
+            ->reduce(function($carry, $order) {
104 104
                 if (($order["type"] ?? "") === "Raw") {
105
-                    return $carry . "_orderByRaw_" . (new Str)->slug($order["sql"]);
105
+                    return $carry."_orderByRaw_".(new Str)->slug($order["sql"]);
106 106
                 }
107 107
 
108
-                return $carry . "_orderBy_" . $order["column"] . "_" . $order["direction"];
108
+                return $carry."_orderBy_".$order["column"]."_".$order["direction"];
109 109
             })
110 110
             ?: "";
111 111
     }
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
     {
115 115
         if (($columns === ["*"]
116 116
                 || $columns === [])
117
-            && (! property_exists($this->query, "columns")
118
-                || ! $this->query->columns)
117
+            && (!property_exists($this->query, "columns")
118
+                || !$this->query->columns)
119 119
         ) {
120 120
             return "";
121 121
         }
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
         if (property_exists($this->query, "columns")
124 124
             && $this->query->columns
125 125
         ) {
126
-            return "_" . implode("_", $this->query->columns);
126
+            return "_".implode("_", $this->query->columns);
127 127
         }
128 128
 
129
-        return "_" . implode("_", $columns);
129
+        return "_".implode("_", $columns);
130 130
     }
131 131
 
132 132
     protected function getTypeClause($where) : string
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
     protected function getValuesClause(array $where = []) : string
142 142
     {
143
-        if (! $where
143
+        if (!$where
144 144
             || in_array($where["type"], ["NotNull", "Null"])
145 145
         ) {
146 146
             return "";
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         $values = $this->getValuesFromWhere($where);
150 150
         $values = $this->getValuesFromBindings($where, $values);
151 151
 
152
-        return "_" . $values;
152
+        return "_".$values;
153 153
     }
154 154
 
155 155
     protected function getValuesFromWhere(array $where) : string
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
     protected function getValuesFromBindings(array $where, string $values) : string
176 176
     {
177 177
         // Fallback to this when the current binding does not exist in the bindings array
178
-        $bindingFallback = __CLASS__ . ':UNKNOWN_BINDING';
178
+        $bindingFallback = __CLASS__.':UNKNOWN_BINDING';
179 179
         $currentBinding = $this->getCurrentBinding('where') ?? $bindingFallback;
180 180
 
181 181
         if ($currentBinding !== $bindingFallback) {
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
             $this->currentBinding++;
184 184
 
185 185
             if ($where["type"] === "between") {
186
-                $values .= "_" . $this->getCurrentBinding('where');
186
+                $values .= "_".$this->getCurrentBinding('where');
187 187
                 $this->currentBinding++;
188 188
             }
189 189
         }
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 
200 200
     protected function getWhereClauses(array $wheres = []) : string
201 201
     {
202
-        return "" . $this->getWheres($wheres)
203
-            ->reduce(function ($carry, $where) {
202
+        return "".$this->getWheres($wheres)
203
+            ->reduce(function($carry, $where) {
204 204
                 $value = $carry;
205 205
                 $value .= $this->getNestedClauses($where);
206 206
                 $value .= $this->getColumnClauses($where);
@@ -214,11 +214,11 @@  discard block
 block discarded – undo
214 214
 
215 215
     protected function getNestedClauses(array $where) : string
216 216
     {
217
-        if (! in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
217
+        if (!in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
218 218
             return "";
219 219
         }
220 220
 
221
-        return "-" . strtolower($where["type"]) . $this->getWhereClauses($where["query"]->wheres);
221
+        return "-".strtolower($where["type"]).$this->getWhereClauses($where["query"]->wheres);
222 222
     }
223 223
 
224 224
     protected function getColumnClauses(array $where) : string
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 
233 233
     protected function getInAndNotInClauses(array $where) : string
234 234
     {
235
-        if (! in_array($where["type"], ["In", "NotIn", "InRaw"])) {
235
+        if (!in_array($where["type"], ["In", "NotIn", "InRaw"])) {
236 236
             return "";
237 237
         }
238 238
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
             $this->currentBinding += count($where["values"]);
245 245
         }
246 246
 
247
-        if (! is_numeric($subquery) && ! is_numeric(str_replace("_", "", $subquery))) {
247
+        if (!is_numeric($subquery) && !is_numeric(str_replace("_", "", $subquery))) {
248 248
             try {
249 249
                 $subquery = Uuid::fromBytes($subquery);
250 250
                 $values = $this->recursiveImplode([$subquery], "_");
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                 continue;
283 283
             }
284 284
 
285
-            $result .= $glue . $value;
285
+            $result .= $glue.$value;
286 286
         }
287 287
 
288 288
         return $result;
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 
291 291
     protected function getRawClauses(array $where) : string
292 292
     {
293
-        if (! in_array($where["type"], ["raw"])) {
293
+        if (!in_array($where["type"], ["raw"])) {
294 294
             return "";
295 295
         }
296 296
 
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
         $clause = "_{$where["boolean"]}";
299 299
 
300 300
         while (count($queryParts) > 1) {
301
-            $clause .= "_" . array_shift($queryParts);
301
+            $clause .= "_".array_shift($queryParts);
302 302
             $clause .= $this->getCurrentBinding('where');
303 303
             $this->currentBinding++;
304 304
         }
@@ -306,10 +306,10 @@  discard block
 block discarded – undo
306 306
         $lastPart = array_shift($queryParts);
307 307
 
308 308
         if ($lastPart) {
309
-            $clause .= "_" . $lastPart;
309
+            $clause .= "_".$lastPart;
310 310
         }
311 311
 
312
-        return "-" . str_replace(" ", "_", $clause);
312
+        return "-".str_replace(" ", "_", $clause);
313 313
     }
314 314
 
315 315
     protected function getOtherClauses(array $where) : string
@@ -345,8 +345,8 @@  discard block
 block discarded – undo
345 345
             return "";
346 346
         }
347 347
 
348
-        return $eagerLoads->keys()->reduce(function ($carry, $related) {
349
-            if (! method_exists($this->model, $related)) {
348
+        return $eagerLoads->keys()->reduce(function($carry, $related) {
349
+            if (!method_exists($this->model, $related)) {
350 350
                 return "{$carry}-{$related}";
351 351
             }
352 352
 
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 
361 361
     protected function getBindingsSlug() : string
362 362
     {
363
-        if (! method_exists($this->model, 'query')) {
363
+        if (!method_exists($this->model, 'query')) {
364 364
             return '';
365 365
         }
366 366
 
Please login to merge, or discard this patch.