Passed
Push — master ( e200e0...bf70a1 )
by Mike
02:28
created
src/Traits/BuilderCaching.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 {
7 7
     public function all($columns = ['*']) : Collection
8 8
     {
9
-        if (! $this->isCachable()) {
9
+        if (!$this->isCachable()) {
10 10
             $this->model->disableModelCaching();
11 11
         }
12 12
 
Please login to merge, or discard this patch.
src/Console/Commands/Clear.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
         $option = $this->option('model');
14 14
 
15
-        if (! $option) {
15
+        if (!$option) {
16 16
             return $this->flushEntireCache();
17 17
         }
18 18
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         $usesCachableTrait = $this->getAllTraitsUsedByClass($option)
37 37
             ->contains("GeneaLabs\LaravelModelCaching\Traits\Cachable");
38 38
 
39
-        if (! $usesCachableTrait) {
39
+        if (!$usesCachableTrait) {
40 40
             $this->error("'{$option}' is not an instance of CachedModel.");
41 41
             $this->line("Only CachedModel instances can be flushed.");
42 42
 
Please login to merge, or discard this patch.
src/Providers/Service.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 
10 10
     public function boot()
11 11
     {
12
-        $configPath = __DIR__ . '/../../config/laravel-model-caching.php';
12
+        $configPath = __DIR__.'/../../config/laravel-model-caching.php';
13 13
         $this->mergeConfigFrom($configPath, 'laravel-model-caching');
14 14
         $this->commands(Clear::class);
15 15
     }
Please login to merge, or discard this patch.
src/CacheTags.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     {
29 29
         $tags = collect($this->eagerLoad)
30 30
             ->keys()
31
-            ->map(function ($relationName) {
31
+            ->map(function($relationName) {
32 32
                 $relation = $this->getRelation($relationName);
33 33
 
34 34
                 return $this->getCachePrefix()
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     protected function getRelation(string $relationName) : Relation
54 54
     {
55 55
         return collect(explode('.', $relationName))
56
-            ->reduce(function ($carry, $name) {
56
+            ->reduce(function($carry, $name) {
57 57
                 $carry = $carry ?: $this->model;
58 58
                 $carry = $this->getRelatedModel($carry);
59 59
 
Please login to merge, or discard this patch.
src/Traits/ModelCaching.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -22,22 +22,22 @@  discard block
 block discarded – undo
22 22
         $key = $instance->makeCacheKey();
23 23
 
24 24
         return $instance->cache($tags)
25
-            ->rememberForever($key, function () use ($columns) {
25
+            ->rememberForever($key, function() use ($columns) {
26 26
                 return parent::all($columns);
27 27
             });
28 28
     }
29 29
 
30 30
     public static function bootCachable()
31 31
     {
32
-        static::created(function ($instance) {
32
+        static::created(function($instance) {
33 33
             $instance->checkCooldownAndFlushAfterPersisting($instance);
34 34
         });
35 35
 
36
-        static::deleted(function ($instance) {
36
+        static::deleted(function($instance) {
37 37
             $instance->checkCooldownAndFlushAfterPersisting($instance);
38 38
         });
39 39
 
40
-        static::saved(function ($instance) {
40
+        static::saved(function($instance) {
41 41
             $instance->checkCooldownAndFlushAfterPersisting($instance);
42 42
         });
43 43
 
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
         //     $instance->checkCooldownAndFlushAfterPersisting($instance);
47 47
         // });
48 48
 
49
-        static::pivotAttached(function ($instance, $secondInstance, $relationship) {
49
+        static::pivotAttached(function($instance, $secondInstance, $relationship) {
50 50
             $instance->checkCooldownAndFlushAfterPersisting($instance, $relationship);
51 51
         });
52 52
 
53
-        static::pivotDetached(function ($instance, $secondInstance, $relationship) {
53
+        static::pivotDetached(function($instance, $secondInstance, $relationship) {
54 54
             $instance->checkCooldownAndFlushAfterPersisting($instance, $relationship);
55 55
         });
56 56
 
57
-        static::pivotUpdated(function ($instance, $secondInstance, $relationship) {
57
+        static::pivotUpdated(function($instance, $secondInstance, $relationship) {
58 58
             $instance->checkCooldownAndFlushAfterPersisting($instance, $relationship);
59 59
         });
60 60
     }
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
     public function newEloquentBuilder($query)
72 72
     {
73
-        if (! $this->isCachable()) {
73
+        if (!$this->isCachable()) {
74 74
             $this->isCachable = false;
75 75
 
76 76
             return new EloquentBuilder($query);
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
         EloquentBuilder $query,
115 115
         int $seconds = null
116 116
     ) : EloquentBuilder {
117
-        if (! $seconds) {
117
+        if (!$seconds) {
118 118
             $seconds = $this->cacheCooldownSeconds;
119 119
         }
120 120
 
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:seconds";
124 124
 
125 125
         $this->cache()
126
-            ->rememberForever($cacheKey, function () use ($seconds) {
126
+            ->rememberForever($cacheKey, function() use ($seconds) {
127 127
                 return $seconds;
128 128
             });
129 129
 
130 130
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:invalidated-at";
131 131
         $this->cache()
132
-            ->rememberForever($cacheKey, function () {
132
+            ->rememberForever($cacheKey, function() {
133 133
                 return (new Carbon)->now();
134 134
             });
135 135
 
Please login to merge, or discard this patch.
src/Traits/Buildable.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 {
8 8
     public function avg($column)
9 9
     {
10
-        if (! $this->isCachable()) {
10
+        if (!$this->isCachable()) {
11 11
             return parent::avg($column);
12 12
         }
13 13
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
     public function count($columns = "*")
20 20
     {
21
-        if (! $this->isCachable()) {
21
+        if (!$this->isCachable()) {
22 22
             return parent::count($columns);
23 23
         }
24 24
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function find($id, $columns = ["*"])
50 50
     {
51
-        if (! $this->isCachable()) {
51
+        if (!$this->isCachable()) {
52 52
             return parent::find($id, $columns);
53 53
         }
54 54
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
     public function first($columns = ["*"])
66 66
     {
67
-        if (! $this->isCachable()) {
67
+        if (!$this->isCachable()) {
68 68
             return parent::first($columns);
69 69
         }
70 70
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 
84 84
     public function get($columns = ["*"])
85 85
     {
86
-        if (! $this->isCachable()) {
86
+        if (!$this->isCachable()) {
87 87
             return parent::get($columns);
88 88
         }
89 89
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
     public function max($column)
118 118
     {
119
-        if (! $this->isCachable()) {
119
+        if (!$this->isCachable()) {
120 120
             return parent::max($column);
121 121
         }
122 122
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 
128 128
     public function min($column)
129 129
     {
130
-        if (! $this->isCachable()) {
130
+        if (!$this->isCachable()) {
131 131
             return parent::min($column);
132 132
         }
133 133
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         $pageName = "page",
143 143
         $page = null
144 144
     ) {
145
-        if (! $this->isCachable()) {
145
+        if (!$this->isCachable()) {
146 146
             return parent::paginate($perPage, $columns, $pageName, $page);
147 147
         }
148 148
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         $result = "";
164 164
 
165 165
         foreach ($items as $key => $value) {
166
-            $result .= $glue . $key . $glue . $value;
166
+            $result .= $glue.$key.$glue.$value;
167 167
         }
168 168
 
169 169
         return $result;
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 
172 172
     public function pluck($column, $key = null)
173 173
     {
174
-        if (! $this->isCachable()) {
174
+        if (!$this->isCachable()) {
175 175
             return parent::pluck($column, $key);
176 176
         }
177 177
 
178
-        $keyDifferentiator = "-pluck_{$column}" . ($key ? "_{$key}" : "");
178
+        $keyDifferentiator = "-pluck_{$column}".($key ? "_{$key}" : "");
179 179
         $cacheKey = $this->makeCacheKey([$column], null, $keyDifferentiator);
180 180
 
181 181
         return $this->cachedValue(func_get_args(), $cacheKey);
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
     public function sum($column)
185 185
     {
186
-        if (! $this->isCachable()) {
186
+        if (!$this->isCachable()) {
187 187
             return parent::sum($column);
188 188
         }
189 189
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 
202 202
     public function value($column)
203 203
     {
204
-        if (! $this->isCachable()) {
204
+        if (!$this->isCachable()) {
205 205
             return parent::value($column);
206 206
         }
207 207
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         return $this->cache($cacheTags)
277 277
             ->rememberForever(
278 278
                 $hashedCacheKey,
279
-                function () use ($arguments, $cacheKey, $method) {
279
+                function() use ($arguments, $cacheKey, $method) {
280 280
                     return [
281 281
                         "key" => $cacheKey,
282 282
                         "value" => parent::{$method}(...$arguments),
Please login to merge, or discard this patch.
src/CacheKey.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 
53 53
     protected function getLimitClause() : string
54 54
     {
55
-        if (! property_exists($this->query, "limit")
56
-            || ! $this->query->limit
55
+        if (!property_exists($this->query, "limit")
56
+            || !$this->query->limit
57 57
         ) {
58 58
             return "";
59 59
         }
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 
75 75
     protected function getOffsetClause() : string
76 76
     {
77
-        if (! property_exists($this->query, "offset")
78
-            || ! $this->query->offset
77
+        if (!property_exists($this->query, "offset")
78
+            || !$this->query->offset
79 79
         ) {
80 80
             return "";
81 81
         }
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 
86 86
     protected function getOrderByClauses() : string
87 87
     {
88
-        if (! property_exists($this->query, "orders")
89
-            || ! $this->query->orders
88
+        if (!property_exists($this->query, "orders")
89
+            || !$this->query->orders
90 90
         ) {
91 91
             return "";
92 92
         }
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
         $orders = collect($this->query->orders);
95 95
 
96 96
         return $orders
97
-            ->reduce(function ($carry, $order) {
97
+            ->reduce(function($carry, $order) {
98 98
                 if (($order["type"] ?? "") === "Raw") {
99
-                    return $carry . "_orderByRaw_" . (new Str)->slug($order["sql"]);
99
+                    return $carry."_orderByRaw_".(new Str)->slug($order["sql"]);
100 100
                 }
101 101
 
102
-                return $carry . "_orderBy_" . $order["column"] . "_" . $order["direction"];
102
+                return $carry."_orderBy_".$order["column"]."_".$order["direction"];
103 103
             })
104 104
             ?: "";
105 105
     }
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
     {
109 109
         if (($columns === ["*"]
110 110
                 || $columns === [])
111
-            && (! property_exists($this->query, "columns")
112
-                || ! $this->query->columns)
111
+            && (!property_exists($this->query, "columns")
112
+                || !$this->query->columns)
113 113
         ) {
114 114
             return "";
115 115
         }
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
         if (property_exists($this->query, "columns")
118 118
             && $this->query->columns
119 119
         ) {
120
-            return "_" . implode("_", $this->query->columns);
120
+            return "_".implode("_", $this->query->columns);
121 121
         }
122 122
 
123
-        return "_" . implode("_", $columns);
123
+        return "_".implode("_", $columns);
124 124
     }
125 125
 
126 126
     protected function getTypeClause($where) : string
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
     protected function getValuesClause(array $where = []) : string
136 136
     {
137
-        if (! $where
137
+        if (!$where
138 138
             || in_array($where["type"], ["NotNull", "Null"])
139 139
         ) {
140 140
             return "";
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
         $values = $this->getValuesFromWhere($where);
144 144
         $values = $this->getValuesFromBindings($where, $values);
145 145
 
146
-        return "_" . $values;
146
+        return "_".$values;
147 147
     }
148 148
 
149 149
     protected function getValuesFromWhere(array $where) : string
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
             $this->currentBinding++;
163 163
 
164 164
             if ($where["type"] === "between") {
165
-                $values .= "_" . $this->query->bindings["where"][$this->currentBinding];
165
+                $values .= "_".$this->query->bindings["where"][$this->currentBinding];
166 166
                 $this->currentBinding++;
167 167
             }
168 168
         }
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 
173 173
     protected function getWhereClauses(array $wheres = []) : string
174 174
     {
175
-        return "" . $this->getWheres($wheres)
176
-            ->reduce(function ($carry, $where) {
175
+        return "".$this->getWheres($wheres)
176
+            ->reduce(function($carry, $where) {
177 177
                 $value = $carry;
178 178
                 $value .= $this->getNestedClauses($where);
179 179
                 $value .= $this->getColumnClauses($where);
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
 
188 188
     protected function getNestedClauses(array $where) : string
189 189
     {
190
-        if (! in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
190
+        if (!in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
191 191
             return "";
192 192
         }
193 193
 
194
-        return "-" . strtolower($where["type"]) . $this->getWhereClauses($where["query"]->wheres);
194
+        return "-".strtolower($where["type"]).$this->getWhereClauses($where["query"]->wheres);
195 195
     }
196 196
 
197 197
     protected function getColumnClauses(array $where) : string
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 
206 206
     protected function getInAndNotInClauses(array $where) : string
207 207
     {
208
-        if (! in_array($where["type"], ["In", "NotIn", "InRaw"])) {
208
+        if (!in_array($where["type"], ["In", "NotIn", "InRaw"])) {
209 209
             return "";
210 210
         }
211 211
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
                 continue;
240 240
             }
241 241
 
242
-            $result .= $glue . $value;
242
+            $result .= $glue.$value;
243 243
         }
244 244
 
245 245
         return $result;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
     protected function getRawClauses(array $where) : string
249 249
     {
250
-        if (! in_array($where["type"], ["raw"])) {
250
+        if (!in_array($where["type"], ["raw"])) {
251 251
             return "";
252 252
         }
253 253
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
         $clause = "_{$where["boolean"]}";
256 256
 
257 257
         while (count($queryParts) > 1) {
258
-            $clause .= "_" . array_shift($queryParts);
258
+            $clause .= "_".array_shift($queryParts);
259 259
             $clause .= $this->query->bindings["where"][$this->currentBinding];
260 260
             $this->currentBinding++;
261 261
         }
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
         $lastPart = array_shift($queryParts);
264 264
 
265 265
         if ($lastPart) {
266
-            $clause .= "_" . $lastPart;
266
+            $clause .= "_".$lastPart;
267 267
         }
268 268
 
269
-        return "-" . str_replace(" ", "_", $clause);
269
+        return "-".str_replace(" ", "_", $clause);
270 270
     }
271 271
 
272 272
     protected function getOtherClauses(array $where) : string
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
             return "";
303 303
         }
304 304
 
305
-        return $eagerLoads->keys()->reduce(function ($carry, $related) {
306
-            if (! method_exists($this->model, $related)) {
305
+        return $eagerLoads->keys()->reduce(function($carry, $related) {
306
+            if (!method_exists($this->model, $related)) {
307 307
                 return "{$carry}-{$related}";
308 308
             }
309 309
 
Please login to merge, or discard this patch.
src/Traits/CachePrefixing.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@
 block discarded – undo
17 17
             : "";
18 18
 
19 19
         return "genealabs:laravel-model-caching:"
20
-            . $this->getConnectionName() . ":"
21
-            . $this->getDatabaseName() . ":"
20
+            . $this->getConnectionName().":"
21
+            . $this->getDatabaseName().":"
22 22
             . $cachePrefix;
23 23
     }
24 24
 
Please login to merge, or discard this patch.
src/Traits/Caching.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -33,18 +33,18 @@  discard block
 block discarded – undo
33 33
 
34 34
     protected function applyScopesToInstance()
35 35
     {
36
-        if (! property_exists($this, "scopes")
36
+        if (!property_exists($this, "scopes")
37 37
             || $this->scopesAreApplied
38 38
         ) {
39 39
             return;
40 40
         }
41 41
 
42 42
         foreach ($this->scopes as $identifier => $scope) {
43
-            if (! isset($this->scopes[$identifier])) {
43
+            if (!isset($this->scopes[$identifier])) {
44 44
                 continue;
45 45
             }
46 46
 
47
-            $this->callScope(function () use ($scope) {
47
+            $this->callScope(function() use ($scope) {
48 48
                 if ($scope instanceof Closure) {
49 49
                     $scope($this);
50 50
                 }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
             $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
99 99
 
100 100
             $this->cache()
101
-                ->rememberForever($cacheKey, function () {
101
+                ->rememberForever($cacheKey, function() {
102 102
                     return (new Carbon)->now();
103 103
                 });
104 104
         }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
     public function getModelCacheCooldown(Model $instance) : array
171 171
     {
172
-        if (! $instance->cacheCooldownSeconds) {
172
+        if (!$instance->cacheCooldownSeconds) {
173 173
             return [null, null, null];
174 174
         }
175 175
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         [$cacheCooldown, $invalidatedAt, $savedAt] = $this
179 179
             ->getCacheCooldownDetails($instance, $cachePrefix, $modelClassName);
180 180
 
181
-        if (! $cacheCooldown || $cacheCooldown === 0) {
181
+        if (!$cacheCooldown || $cacheCooldown === 0) {
182 182
             return [null, null, null];
183 183
         }
184 184
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     {
208 208
         [$cacheCooldown, $invalidatedAt] = $this->getModelCacheCooldown($instance);
209 209
 
210
-        if (! $cacheCooldown
210
+        if (!$cacheCooldown
211 211
             || (new Carbon)->now()->diffInSeconds($invalidatedAt) < $cacheCooldown
212 212
         ) {
213 213
             return;
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
     {
233 233
         [$cacheCooldown, $invalidatedAt] = $instance->getModelCacheCooldown($instance);
234 234
 
235
-        if (! $cacheCooldown) {
235
+        if (!$cacheCooldown) {
236 236
             $instance->flushCache();
237 237
 
238 238
             if ($relationship) {
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
     public function isCachable() : bool
261 261
     {
262 262
         return $this->isCachable
263
-            && ! config('laravel-model-caching.disabled');
263
+            && !config('laravel-model-caching.disabled');
264 264
     }
265 265
 
266 266
     protected function setCacheCooldownSavedAtTimestamp(Model $instance)
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
271 271
 
272 272
         $instance->cache()
273
-            ->rememberForever($cacheKey, function () {
273
+            ->rememberForever($cacheKey, function() {
274 274
                 return (new Carbon)->now();
275 275
             });
276 276
     }
Please login to merge, or discard this patch.