Completed
Push — master ( 1fe377...25ce57 )
by Mike
19s queued 12s
created
src/Traits/Caching.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     protected function applyScopesToInstance()
49 49
     {
50 50
         if (
51
-            ! property_exists($this, "scopes")
51
+            !property_exists($this, "scopes")
52 52
             || $this->scopesAreApplied
53 53
             || $this->withoutAllGlobalScopes
54 54
         ) {
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 
58 58
         foreach ($this->scopes as $identifier => $scope) {
59 59
             if (
60
-                ! isset($this->scopes[$identifier])
60
+                !isset($this->scopes[$identifier])
61 61
                 || isset($this->withoutGlobalScopes[$identifier])
62 62
             ) {
63 63
                 continue;
64 64
             }
65 65
 
66
-            $this->callScope(function () use ($scope) {
66
+            $this->callScope(function() use ($scope) {
67 67
                 if ($scope instanceof Closure) {
68 68
                     $scope($this);
69 69
                 }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
             $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
123 123
 
124 124
             $this->cache()
125
-                ->rememberForever($cacheKey, function () {
125
+                ->rememberForever($cacheKey, function() {
126 126
                     return (new Carbon)->now();
127 127
                 });
128 128
         }
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 
202 202
     public function getModelCacheCooldown(Model $instance) : array
203 203
     {
204
-        if (! $instance->cacheCooldownSeconds) {
204
+        if (!$instance->cacheCooldownSeconds) {
205 205
             return [null, null, null];
206 206
         }
207 207
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         [$cacheCooldown, $invalidatedAt, $savedAt] = $this
211 211
             ->getCacheCooldownDetails($instance, $cachePrefix, $modelClassName);
212 212
 
213
-        if (! $cacheCooldown || $cacheCooldown === 0) {
213
+        if (!$cacheCooldown || $cacheCooldown === 0) {
214 214
             return [null, null, null];
215 215
         }
216 216
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         [$cacheCooldown, $invalidatedAt] = $this->getModelCacheCooldown($instance);
241 241
 
242 242
         if (
243
-            ! $cacheCooldown
243
+            !$cacheCooldown
244 244
             || (new Carbon)->now()->diffInSeconds($invalidatedAt) < $cacheCooldown
245 245
         ) {
246 246
             return;
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
     {
266 266
         [$cacheCooldown, $invalidatedAt] = $instance->getModelCacheCooldown($instance);
267 267
 
268
-        if (! $cacheCooldown) {
268
+        if (!$cacheCooldown) {
269 269
             $instance->flushCache();
270 270
 
271 271
             if ($relationship) {
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 
293 293
     public function isCachable() : bool
294 294
     {
295
-        $isCacheDisabled = ! Container::getInstance()
295
+        $isCacheDisabled = !Container::getInstance()
296 296
             ->make("config")
297 297
             ->get("laravel-model-caching.enabled");
298 298
         $allRelationshipsAreCachable = true;
@@ -304,9 +304,9 @@  discard block
 block discarded – undo
304 304
             $allRelationshipsAreCachable = collect($this
305 305
                 ->eagerLoad)
306 306
                 ->keys()
307
-                ->reduce(function ($carry, $related) {
307
+                ->reduce(function($carry, $related) {
308 308
                     if (
309
-                        ! method_exists($this->model, $related)
309
+                        !method_exists($this->model, $related)
310 310
                         || $carry === false
311 311
                     ) {
312 312
                         return $carry;
@@ -315,8 +315,8 @@  discard block
 block discarded – undo
315 315
                     $relatedModel = $this->model->$related()->getRelated();
316 316
 
317 317
                     if (
318
-                        ! method_exists($relatedModel, "isCachable")
319
-                        || ! $relatedModel->isCachable()
318
+                        !method_exists($relatedModel, "isCachable")
319
+                        || !$relatedModel->isCachable()
320 320
                     ) {
321 321
                         return false;
322 322
                     }
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
         }
328 328
 
329 329
         return $this->isCachable
330
-            && ! $isCacheDisabled
330
+            && !$isCacheDisabled
331 331
             && $allRelationshipsAreCachable;
332 332
     }
333 333
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
339 339
 
340 340
         $instance->cache()
341
-            ->rememberForever($cacheKey, function () {
341
+            ->rememberForever($cacheKey, function() {
342 342
                 return (new Carbon)->now();
343 343
             });
344 344
     }
Please login to merge, or discard this patch.
tests/Integration/CachedBuilder/BelongsToManyTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -200,7 +200,7 @@
 block discarded – undo
200 200
             ?? null;
201 201
 
202 202
         $this->assertEmpty(array_diff(
203
-            Book::find($bookId)->stores()->pluck((new Store)->getTable() . '.id')->toArray(),
203
+            Book::find($bookId)->stores()->pluck((new Store)->getTable().'.id')->toArray(),
204 204
             $newStores->pluck('id')->toArray()
205 205
         ));
206 206
         $this->assertNotEmpty($result);
Please login to merge, or discard this patch.
src/CacheKey.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 
61 61
     protected function getBindingsSlug() : string
62 62
     {
63
-        if (! method_exists($this->model, 'query')) {
63
+        if (!method_exists($this->model, 'query')) {
64 64
             return '';
65 65
         }
66 66
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
     protected function getInAndNotInClauses(array $where) : string
98 98
     {
99
-        if (! in_array($where["type"], ["In", "NotIn", "InRaw"])) {
99
+        if (!in_array($where["type"], ["In", "NotIn", "InRaw"])) {
100 100
             return "";
101 101
         }
102 102
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             $this->currentBinding += count($where["values"]);
109 109
         }
110 110
 
111
-        if (! is_numeric($subquery) && ! is_numeric(str_replace("_", "", $subquery))) {
111
+        if (!is_numeric($subquery) && !is_numeric(str_replace("_", "", $subquery))) {
112 112
             try {
113 113
                 $subquery = Uuid::fromBytes($subquery);
114 114
                 $values = $this->recursiveImplode([$subquery], "_");
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 
129 129
     protected function getLimitClause() : string
130 130
     {
131
-        if (! property_exists($this->query, "limit")
132
-            || ! $this->query->limit
131
+        if (!property_exists($this->query, "limit")
132
+            || !$this->query->limit
133 133
         ) {
134 134
             return "";
135 135
         }
@@ -144,17 +144,17 @@  discard block
 block discarded – undo
144 144
 
145 145
     protected function getNestedClauses(array $where) : string
146 146
     {
147
-        if (! in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
147
+        if (!in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
148 148
             return "";
149 149
         }
150 150
 
151
-        return "-" . strtolower($where["type"]) . $this->getWhereClauses($where["query"]->wheres);
151
+        return "-".strtolower($where["type"]).$this->getWhereClauses($where["query"]->wheres);
152 152
     }
153 153
 
154 154
     protected function getOffsetClause() : string
155 155
     {
156
-        if (! property_exists($this->query, "offset")
157
-            || ! $this->query->offset
156
+        if (!property_exists($this->query, "offset")
157
+            || !$this->query->offset
158 158
         ) {
159 159
             return "";
160 160
         }
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 
165 165
     protected function getOrderByClauses() : string
166 166
     {
167
-        if (! property_exists($this->query, "orders")
168
-            || ! $this->query->orders
167
+        if (!property_exists($this->query, "orders")
168
+            || !$this->query->orders
169 169
         ) {
170 170
             return "";
171 171
         }
@@ -173,9 +173,9 @@  discard block
 block discarded – undo
173 173
         $orders = collect($this->query->orders);
174 174
         
175 175
         return $orders
176
-            ->reduce(function ($carry, $order) {
176
+            ->reduce(function($carry, $order) {
177 177
                 if (($order["type"] ?? "") === "Raw") {
178
-                    return $carry . "_orderByRaw_" . (new Str)->slug($order["sql"]);
178
+                    return $carry."_orderByRaw_".(new Str)->slug($order["sql"]);
179 179
                 }
180 180
 
181 181
                 return sprintf(
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
     {
209 209
         if (($columns === ["*"]
210 210
                 || $columns === [])
211
-            && (! property_exists($this->query, "columns")
212
-                || ! $this->query->columns)
211
+            && (!property_exists($this->query, "columns")
212
+                || !$this->query->columns)
213 213
         ) {
214 214
             return "";
215 215
         }
@@ -217,19 +217,19 @@  discard block
 block discarded – undo
217 217
         if (property_exists($this->query, "columns")
218 218
             && $this->query->columns
219 219
         ) {
220
-            $columns = array_map(function ($column) {                
220
+            $columns = array_map(function($column) {                
221 221
                 return $this->expressionToString($column);
222 222
             }, $this->query->columns);
223 223
 
224
-            return "_" . implode("_", $columns);
224
+            return "_".implode("_", $columns);
225 225
         }
226 226
 
227
-        return "_" . implode("_", $columns);
227
+        return "_".implode("_", $columns);
228 228
     }
229 229
 
230 230
     protected function getRawClauses(array $where) : string
231 231
     {
232
-        if (! in_array($where["type"], ["raw"])) {
232
+        if (!in_array($where["type"], ["raw"])) {
233 233
             return "";
234 234
         }
235 235
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
         $clause = "_{$where["boolean"]}";
238 238
 
239 239
         while (count($queryParts) > 1) {
240
-            $clause .= "_" . array_shift($queryParts);
240
+            $clause .= "_".array_shift($queryParts);
241 241
             $clause .= $this->getCurrentBinding("where");
242 242
             $this->currentBinding++;
243 243
         }
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
         $lastPart = array_shift($queryParts);
246 246
 
247 247
         if ($lastPart) {
248
-            $clause .= "_" . $lastPart;
248
+            $clause .= "_".$lastPart;
249 249
         }
250 250
 
251
-        return "-" . str_replace(" ", "_", $clause);
251
+        return "-".str_replace(" ", "_", $clause);
252 252
     }
253 253
 
254 254
     protected function getTableSlug() : string
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 
269 269
     protected function getValuesClause(array $where = []) : string
270 270
     {
271
-        if (! $where
271
+        if (!$where
272 272
             || in_array($where["type"], ["NotNull", "Null"])
273 273
         ) {
274 274
             return "";
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
         $values = $this->getValuesFromWhere($where);
278 278
         $values = $this->getValuesFromBindings($where, $values);
279 279
 
280
-        return "_" . $values;
280
+        return "_".$values;
281 281
     }
282 282
 
283 283
     protected function getValuesFromWhere(array $where) : string
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 
307 307
     protected function getValuesFromBindings(array $where, string $values) : string
308 308
     {
309
-        $bindingFallback = __CLASS__ . ':UNKNOWN_BINDING';
309
+        $bindingFallback = __CLASS__.':UNKNOWN_BINDING';
310 310
         $currentBinding = $this->getCurrentBinding("where", $bindingFallback);
311 311
 
312 312
         if ($currentBinding !== $bindingFallback) {
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             $this->currentBinding++;
315 315
 
316 316
             if ($where["type"] === "between") {
317
-                $values .= "_" . $this->getCurrentBinding("where");
317
+                $values .= "_".$this->getCurrentBinding("where");
318 318
                 $this->currentBinding++;
319 319
             }
320 320
         }
@@ -330,8 +330,8 @@  discard block
 block discarded – undo
330 330
 
331 331
     protected function getWhereClauses(array $wheres = []) : string
332 332
     {
333
-        return "" . $this->getWheres($wheres)
334
-            ->reduce(function ($carry, $where) {
333
+        return "".$this->getWheres($wheres)
334
+            ->reduce(function($carry, $where) {
335 335
                 $value = $carry;
336 336
                 $value .= $this->getNestedClauses($where);
337 337
                 $value .= $this->getColumnClauses($where);
@@ -364,8 +364,8 @@  discard block
 block discarded – undo
364 364
             return "";
365 365
         }
366 366
 
367
-        return $eagerLoads->keys()->reduce(function ($carry, $related) {
368
-            if (! method_exists($this->model, $related)) {
367
+        return $eagerLoads->keys()->reduce(function($carry, $related) {
368
+            if (!method_exists($this->model, $related)) {
369 369
                 return "{$carry}-{$related}";
370 370
             }
371 371
 
@@ -397,13 +397,13 @@  discard block
 block discarded – undo
397 397
                 continue;
398 398
             }
399 399
 
400
-            $result .= $glue . $value;
400
+            $result .= $glue.$value;
401 401
         }
402 402
 
403 403
         return $result;
404 404
     }
405 405
 
406
-    private function processEnum(\BackedEnum|\UnitEnum|Expression|string $value): string
406
+    private function processEnum(\BackedEnum | \UnitEnum | Expression | string $value): string
407 407
     {
408 408
         if ($value instanceof \BackedEnum) {
409 409
             return $value->value;
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
         return array_map(fn($value) => $this->processEnum($value), $values);
422 422
     }
423 423
 
424
-    private function expressionToString(Expression|string $value): string
424
+    private function expressionToString(Expression | string $value): string
425 425
     {
426 426
         if (is_string($value)) {
427 427
             return $value;
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -85,9 +85,9 @@
 block discarded – undo
85 85
             $where["first"] = $this->expressionToString($where["first"]);
86 86
         }
87 87
         
88
-		if ($where["second"] instanceof Expression) {
89
-			$where["second"] = $this->expressionToString($where["second"]);
90
-		}
88
+        if ($where["second"] instanceof Expression) {
89
+            $where["second"] = $this->expressionToString($where["second"]);
90
+        }
91 91
         
92 92
         return "-{$where["boolean"]}_{$where["first"]}_{$where["operator"]}_{$where["second"]}";
93 93
     }
Please login to merge, or discard this patch.
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
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         $page = null,
162 162
         $total = null
163 163
     ) {
164
-        if (! $this->isCachable()) {
164
+        if (!$this->isCachable()) {
165 165
             return parent::paginate($perPage, $columns, $pageName, $page);
166 166
         }
167 167
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         $result = "";
192 192
 
193 193
         foreach ($items as $key => $value) {
194
-            $result .= $glue . $key . $glue . $value;
194
+            $result .= $glue.$key.$glue.$value;
195 195
         }
196 196
 
197 197
         return $result;
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 
200 200
     public function pluck($column, $key = null)
201 201
     {
202
-        if (! $this->isCachable()) {
202
+        if (!$this->isCachable()) {
203 203
             return parent::pluck($column, $key);
204 204
         }
205 205
 
206
-        $keyDifferentiator = "-pluck_{$column}" . ($key ? "_{$key}" : "");
206
+        $keyDifferentiator = "-pluck_{$column}".($key ? "_{$key}" : "");
207 207
         $cacheKey = $this->makeCacheKey([$column], null, $keyDifferentiator);
208 208
 
209 209
         return $this->cachedValue(func_get_args(), $cacheKey);
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 
212 212
     public function sum($column)
213 213
     {
214
-        if (! $this->isCachable()) {
214
+        if (!$this->isCachable()) {
215 215
             return parent::sum($column);
216 216
         }
217 217
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
     public function value($column)
233 233
     {
234
-        if (! $this->isCachable()) {
234
+        if (!$this->isCachable()) {
235 235
             return parent::value($column);
236 236
         }
237 237
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
         return $this->cache($cacheTags)
307 307
             ->rememberForever(
308 308
                 $hashedCacheKey,
309
-                function () use ($arguments, $cacheKey, $method) {
309
+                function() use ($arguments, $cacheKey, $method) {
310 310
                     return [
311 311
                         "key" => $cacheKey,
312 312
                         "value" => parent::{$method}(...$arguments),
Please login to merge, or discard this patch.