Completed
Push — master ( efaeb5...ff303d )
by Mike
15s queued 12s
created
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
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
     protected function getBindingsSlug() : string
55 55
     {
56
-        if (! method_exists($this->model, 'query')) {
56
+        if (!method_exists($this->model, 'query')) {
57 57
             return '';
58 58
         }
59 59
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
     protected function getInAndNotInClauses(array $where) : string
83 83
     {
84
-        if (! in_array($where["type"], ["In", "NotIn", "InRaw"])) {
84
+        if (!in_array($where["type"], ["In", "NotIn", "InRaw"])) {
85 85
             return "";
86 86
         }
87 87
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             $this->currentBinding += count($where["values"]);
94 94
         }
95 95
 
96
-        if (! is_numeric($subquery) && ! is_numeric(str_replace("_", "", $subquery))) {
96
+        if (!is_numeric($subquery) && !is_numeric(str_replace("_", "", $subquery))) {
97 97
             try {
98 98
                 $subquery = Uuid::fromBytes($subquery);
99 99
                 $values = $this->recursiveImplode([$subquery], "_");
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
 
114 114
     protected function getLimitClause() : string
115 115
     {
116
-        if (! property_exists($this->query, "limit")
117
-            || ! $this->query->limit
116
+        if (!property_exists($this->query, "limit")
117
+            || !$this->query->limit
118 118
         ) {
119 119
             return "";
120 120
         }
@@ -129,17 +129,17 @@  discard block
 block discarded – undo
129 129
 
130 130
     protected function getNestedClauses(array $where) : string
131 131
     {
132
-        if (! in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
132
+        if (!in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
133 133
             return "";
134 134
         }
135 135
 
136
-        return "-" . strtolower($where["type"]) . $this->getWhereClauses($where["query"]->wheres);
136
+        return "-".strtolower($where["type"]).$this->getWhereClauses($where["query"]->wheres);
137 137
     }
138 138
 
139 139
     protected function getOffsetClause() : string
140 140
     {
141
-        if (! property_exists($this->query, "offset")
142
-            || ! $this->query->offset
141
+        if (!property_exists($this->query, "offset")
142
+            || !$this->query->offset
143 143
         ) {
144 144
             return "";
145 145
         }
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 
150 150
     protected function getOrderByClauses() : string
151 151
     {
152
-        if (! property_exists($this->query, "orders")
153
-            || ! $this->query->orders
152
+        if (!property_exists($this->query, "orders")
153
+            || !$this->query->orders
154 154
         ) {
155 155
             return "";
156 156
         }
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
         $orders = collect($this->query->orders);
159 159
 
160 160
         return $orders
161
-            ->reduce(function ($carry, $order) {
161
+            ->reduce(function($carry, $order) {
162 162
                 if (($order["type"] ?? "") === "Raw") {
163
-                    return $carry . "_orderByRaw_" . (new Str)->slug($order["sql"]);
163
+                    return $carry."_orderByRaw_".(new Str)->slug($order["sql"]);
164 164
                 }
165 165
 
166
-                return $carry . "_orderBy_" . $order["column"] . "_" . $order["direction"];
166
+                return $carry."_orderBy_".$order["column"]."_".$order["direction"];
167 167
             })
168 168
             ?: "";
169 169
     }
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
     {
185 185
         if (($columns === ["*"]
186 186
                 || $columns === [])
187
-            && (! property_exists($this->query, "columns")
188
-                || ! $this->query->columns)
187
+            && (!property_exists($this->query, "columns")
188
+                || !$this->query->columns)
189 189
         ) {
190 190
             return "";
191 191
         }
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
         if (property_exists($this->query, "columns")
194 194
             && $this->query->columns
195 195
         ) {
196
-            return "_" . implode("_", $this->query->columns);
196
+            return "_".implode("_", $this->query->columns);
197 197
         }
198 198
 
199
-        return "_" . implode("_", $columns);
199
+        return "_".implode("_", $columns);
200 200
     }
201 201
 
202 202
     protected function getRawClauses(array $where) : string
203 203
     {
204
-        if (! in_array($where["type"], ["raw"])) {
204
+        if (!in_array($where["type"], ["raw"])) {
205 205
             return "";
206 206
         }
207 207
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         $clause = "_{$where["boolean"]}";
210 210
 
211 211
         while (count($queryParts) > 1) {
212
-            $clause .= "_" . array_shift($queryParts);
212
+            $clause .= "_".array_shift($queryParts);
213 213
             $clause .= $this->getCurrentBinding("where");
214 214
             $this->currentBinding++;
215 215
         }
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
         $lastPart = array_shift($queryParts);
218 218
 
219 219
         if ($lastPart) {
220
-            $clause .= "_" . $lastPart;
220
+            $clause .= "_".$lastPart;
221 221
         }
222 222
 
223
-        return "-" . str_replace(" ", "_", $clause);
223
+        return "-".str_replace(" ", "_", $clause);
224 224
     }
225 225
 
226 226
     protected function getTableSlug() : string
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 
241 241
     protected function getValuesClause(array $where = []) : string
242 242
     {
243
-        if (! $where
243
+        if (!$where
244 244
             || in_array($where["type"], ["NotNull", "Null"])
245 245
         ) {
246 246
             return "";
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
         $values = $this->getValuesFromWhere($where);
250 250
         $values = $this->getValuesFromBindings($where, $values);
251 251
 
252
-        return "_" . $values;
252
+        return "_".$values;
253 253
     }
254 254
 
255 255
     protected function getValuesFromWhere(array $where) : string
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 
275 275
     protected function getValuesFromBindings(array $where, string $values) : string
276 276
     {
277
-        $bindingFallback = __CLASS__ . ':UNKNOWN_BINDING';
277
+        $bindingFallback = __CLASS__.':UNKNOWN_BINDING';
278 278
         $currentBinding = $this->getCurrentBinding("where", $bindingFallback);
279 279
 
280 280
         if ($currentBinding !== $bindingFallback) {
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
             $this->currentBinding++;
283 283
 
284 284
             if ($where["type"] === "between") {
285
-                $values .= "_" . $this->getCurrentBinding("where");
285
+                $values .= "_".$this->getCurrentBinding("where");
286 286
                 $this->currentBinding++;
287 287
             }
288 288
         }
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
 
299 299
     protected function getWhereClauses(array $wheres = []) : string
300 300
     {
301
-        return "" . $this->getWheres($wheres)
302
-            ->reduce(function ($carry, $where) {
301
+        return "".$this->getWheres($wheres)
302
+            ->reduce(function($carry, $where) {
303 303
                 $value = $carry;
304 304
                 $value .= $this->getNestedClauses($where);
305 305
                 $value .= $this->getColumnClauses($where);
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
             return "";
333 333
         }
334 334
 
335
-        return $eagerLoads->keys()->reduce(function ($carry, $related) {
336
-            if (! method_exists($this->model, $related)) {
335
+        return $eagerLoads->keys()->reduce(function($carry, $related) {
336
+            if (!method_exists($this->model, $related)) {
337 337
                 return "{$carry}-{$related}";
338 338
             }
339 339
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
                 continue;
366 366
             }
367 367
 
368
-            $result .= $glue . $value;
368
+            $result .= $glue.$value;
369 369
         }
370 370
 
371 371
         return $result;
Please login to merge, or discard this patch.
src/Traits/Caching.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -43,18 +43,18 @@  discard block
 block discarded – undo
43 43
 
44 44
     protected function applyScopesToInstance()
45 45
     {
46
-        if (! property_exists($this, "scopes")
46
+        if (!property_exists($this, "scopes")
47 47
             || $this->scopesAreApplied
48 48
         ) {
49 49
             return;
50 50
         }
51 51
 
52 52
         foreach ($this->scopes as $identifier => $scope) {
53
-            if (! isset($this->scopes[$identifier])) {
53
+            if (!isset($this->scopes[$identifier])) {
54 54
                 continue;
55 55
             }
56 56
 
57
-            $this->callScope(function () use ($scope) {
57
+            $this->callScope(function() use ($scope) {
58 58
                 if ($scope instanceof Closure) {
59 59
                     $scope($this);
60 60
                 }
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
             $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
113 113
 
114 114
             $this->cache()
115
-                ->rememberForever($cacheKey, function () {
115
+                ->rememberForever($cacheKey, function() {
116 116
                     return (new Carbon)->now();
117 117
                 });
118 118
         }
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 
190 190
     public function getModelCacheCooldown(Model $instance) : array
191 191
     {
192
-        if (! $instance->cacheCooldownSeconds) {
192
+        if (!$instance->cacheCooldownSeconds) {
193 193
             return [null, null, null];
194 194
         }
195 195
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         [$cacheCooldown, $invalidatedAt, $savedAt] = $this
199 199
             ->getCacheCooldownDetails($instance, $cachePrefix, $modelClassName);
200 200
 
201
-        if (! $cacheCooldown || $cacheCooldown === 0) {
201
+        if (!$cacheCooldown || $cacheCooldown === 0) {
202 202
             return [null, null, null];
203 203
         }
204 204
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
     {
228 228
         [$cacheCooldown, $invalidatedAt] = $this->getModelCacheCooldown($instance);
229 229
 
230
-        if (! $cacheCooldown
230
+        if (!$cacheCooldown
231 231
             || (new Carbon)->now()->diffInSeconds($invalidatedAt) < $cacheCooldown
232 232
         ) {
233 233
             return;
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
     {
253 253
         [$cacheCooldown, $invalidatedAt] = $instance->getModelCacheCooldown($instance);
254 254
 
255
-        if (! $cacheCooldown) {
255
+        if (!$cacheCooldown) {
256 256
             $instance->flushCache();
257 257
 
258 258
             if ($relationship) {
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 
280 280
     public function isCachable() : bool
281 281
     {
282
-        $isCacheDisabled = ! Container::getInstance()
282
+        $isCacheDisabled = !Container::getInstance()
283 283
             ->make("config")
284 284
             ->get("laravel-model-caching.enabled");
285 285
         $allRelationshipsAreCachable = true;
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
             $allRelationshipsAreCachable = collect($this
291 291
                 ->eagerLoad)
292 292
                 ->keys()
293
-                ->reduce(function ($carry, $related) {
294
-                    if (! method_exists($this->model, $related)
293
+                ->reduce(function($carry, $related) {
294
+                    if (!method_exists($this->model, $related)
295 295
                         || $carry === false
296 296
                     ) {
297 297
                         return $carry;
@@ -299,8 +299,8 @@  discard block
 block discarded – undo
299 299
         
300 300
                     $relatedModel = $this->model->$related()->getRelated();
301 301
 
302
-                    if (! method_exists($relatedModel, "isCachable")
303
-                        || ! $relatedModel->isCachable()
302
+                    if (!method_exists($relatedModel, "isCachable")
303
+                        || !$relatedModel->isCachable()
304 304
                     ) {
305 305
                         return false;
306 306
                     }
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
         }
312 312
 
313 313
         return $this->isCachable
314
-            && ! $isCacheDisabled
314
+            && !$isCacheDisabled
315 315
             && $allRelationshipsAreCachable;
316 316
     }
317 317
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
323 323
 
324 324
         $instance->cache()
325
-            ->rememberForever($cacheKey, function () {
325
+            ->rememberForever($cacheKey, function() {
326 326
                 return (new Carbon)->now();
327 327
             });
328 328
     }
Please login to merge, or discard this patch.