Passed
Push — master ( 3893f1...244d8c )
by Mike
03:13
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/CachePrefixing.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,10 +5,10 @@
 block discarded – undo
5 5
     protected function getCachePrefix() : string
6 6
     {
7 7
         return "genealabs:laravel-model-caching:"
8
-            . $this->getConnectionName() . ":"
9
-            . $this->getDatabaseName() . ":"
8
+            . $this->getConnectionName().":"
9
+            . $this->getDatabaseName().":"
10 10
             . (config("laravel-model-caching.cache-prefix")
11
-                ? config("laravel-model-caching.cache-prefix", "") . ":"
11
+                ? config("laravel-model-caching.cache-prefix", "").":"
12 12
                 : "");
13 13
     }
14 14
 
Please login to merge, or discard this patch.
src/CacheKey.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 
55 55
     protected function getLimitClause() : string
56 56
     {
57
-        if (! property_exists($this->query, "limit")
58
-            || ! $this->query->limit
57
+        if (!property_exists($this->query, "limit")
58
+            || !$this->query->limit
59 59
         ) {
60 60
             return "";
61 61
         }
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 
77 77
     protected function getOffsetClause() : string
78 78
     {
79
-        if (! property_exists($this->query, "offset")
80
-            || ! $this->query->offset
79
+        if (!property_exists($this->query, "offset")
80
+            || !$this->query->offset
81 81
         ) {
82 82
             return "";
83 83
         }
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 
88 88
     protected function getOrderByClauses() : string
89 89
     {
90
-        if (! property_exists($this->query, "orders")
91
-            || ! $this->query->orders
90
+        if (!property_exists($this->query, "orders")
91
+            || !$this->query->orders
92 92
         ) {
93 93
             return "";
94 94
         }
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
         $orders = collect($this->query->orders);
97 97
 
98 98
         return $orders
99
-            ->reduce(function ($carry, $order) {
99
+            ->reduce(function($carry, $order) {
100 100
                 if (($order["type"] ?? "") === "Raw") {
101
-                    return $carry . "_orderByRaw_" . (new Str)->slug($order["sql"]);
101
+                    return $carry."_orderByRaw_".(new Str)->slug($order["sql"]);
102 102
                 }
103 103
 
104
-                return $carry . "_orderBy_" . $order["column"] . "_" . $order["direction"];
104
+                return $carry."_orderBy_".$order["column"]."_".$order["direction"];
105 105
             })
106 106
             ?: "";
107 107
     }
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
     {
111 111
         if (($columns === ["*"]
112 112
                 || $columns === [])
113
-            && (! property_exists($this->query, "columns")
114
-                || ! $this->query->columns)
113
+            && (!property_exists($this->query, "columns")
114
+                || !$this->query->columns)
115 115
         ) {
116 116
             return "";
117 117
         }
@@ -119,10 +119,10 @@  discard block
 block discarded – undo
119 119
         if (property_exists($this->query, "columns")
120 120
             && $this->query->columns
121 121
         ) {
122
-            return "_" . implode("_", $this->query->columns);
122
+            return "_".implode("_", $this->query->columns);
123 123
         }
124 124
 
125
-        return "_" . implode("_", $columns);
125
+        return "_".implode("_", $columns);
126 126
     }
127 127
 
128 128
     protected function getTypeClause($where) : string
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
     protected function getValuesClause(array $where = []) : string
138 138
     {
139
-        if (! $where
139
+        if (!$where
140 140
             || in_array($where["type"], ["NotNull", "Null"])
141 141
         ) {
142 142
             return "";
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         $values = $this->getValuesFromWhere($where);
146 146
         $values = $this->getValuesFromBindings($where, $values);
147 147
 
148
-        return "_" . $values;
148
+        return "_".$values;
149 149
     }
150 150
 
151 151
     protected function getValuesFromWhere(array $where) : string
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
             $subKey = str_replace($prefix, "", $subKey);
158 158
             $subKey = str_replace($this->getModelSlug(), "", $subKey);
159 159
             $classParts = explode("\\", get_class($this->model));
160
-            $subKey = strtolower(array_pop($classParts)) . $subKey;
160
+            $subKey = strtolower(array_pop($classParts)).$subKey;
161 161
 
162 162
             return $subKey;
163 163
         }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
             $this->currentBinding++;
177 177
 
178 178
             if ($where["type"] === "between") {
179
-                $values .= "_" . $this->query->bindings["where"][$this->currentBinding];
179
+                $values .= "_".$this->query->bindings["where"][$this->currentBinding];
180 180
                 $this->currentBinding++;
181 181
             }
182 182
         }
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 
187 187
     protected function getWhereClauses(array $wheres = []) : string
188 188
     {
189
-        return "" . $this->getWheres($wheres)
190
-            ->reduce(function ($carry, $where) {
189
+        return "".$this->getWheres($wheres)
190
+            ->reduce(function($carry, $where) {
191 191
                 $value = $carry;
192 192
                 $value .= $this->getNestedClauses($where);
193 193
                 $value .= $this->getColumnClauses($where);
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 
202 202
     protected function getNestedClauses(array $where) : string
203 203
     {
204
-        if (! in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
204
+        if (!in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
205 205
             return "";
206 206
         }
207 207
 
208
-        return "-" . strtolower($where["type"]) . $this->getWhereClauses($where["query"]->wheres);
208
+        return "-".strtolower($where["type"]).$this->getWhereClauses($where["query"]->wheres);
209 209
     }
210 210
 
211 211
     protected function getColumnClauses(array $where) : string
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
     protected function getInClauses(array $where) : string
221 221
     {
222
-        if (! in_array($where["type"], ["In"])) {
222
+        if (!in_array($where["type"], ["In"])) {
223 223
             return "";
224 224
         }
225 225
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
     protected function getInAndNotInClauses(array $where) : string
233 233
     {
234
-        if (! in_array($where["type"], ["In", "NotIn", "InRaw"])) {
234
+        if (!in_array($where["type"], ["In", "NotIn", "InRaw"])) {
235 235
             return "";
236 236
         }
237 237
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
                 continue;
270 270
             }
271 271
 
272
-            $result .= $glue . $value;
272
+            $result .= $glue.$value;
273 273
         }
274 274
 
275 275
         return $result;
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 
278 278
     protected function getRawClauses(array $where) : string
279 279
     {
280
-        if (! in_array($where["type"], ["raw"])) {
280
+        if (!in_array($where["type"], ["raw"])) {
281 281
             return "";
282 282
         }
283 283
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
         $clause = "_{$where["boolean"]}";
286 286
 
287 287
         while (count($queryParts) > 1) {
288
-            $clause .= "_" . array_shift($queryParts);
288
+            $clause .= "_".array_shift($queryParts);
289 289
             $clause .= $this->query->bindings["where"][$this->currentBinding];
290 290
             $this->currentBinding++;
291 291
         }
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
         $lastPart = array_shift($queryParts);
294 294
 
295 295
         if ($lastPart) {
296
-            $clause .= "_" . $lastPart;
296
+            $clause .= "_".$lastPart;
297 297
         }
298 298
 
299
-        return "-" . str_replace(" ", "_", $clause);
299
+        return "-".str_replace(" ", "_", $clause);
300 300
     }
301 301
 
302 302
     protected function getOtherClauses(array $where) : string
@@ -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
 
Please login to merge, or discard this patch.
src/CachedBelongsToMany.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
     {
18 18
         $relation = parent::getRelation($name);
19 19
 
20
-        if (! $this->isCachable()
20
+        if (!$this->isCachable()
21 21
             && is_a($relation->getQuery(), self::class)
22 22
         ) {
23 23
             $relation->getQuery()->disableModelCaching();
Please login to merge, or discard this patch.
src/Traits/Buildable.php 1 patch
Spacing   +16 added lines, -16 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,11 +64,11 @@  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
 
71
-        if (! is_array($columns)) {
71
+        if (!is_array($columns)) {
72 72
             $columns = [$columns];
73 73
         }
74 74
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
     public function get($columns = ["*"])
89 89
     {
90
-        if (! $this->isCachable()) {
90
+        if (!$this->isCachable()) {
91 91
             return parent::get($columns);
92 92
         }
93 93
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
     public function max($column)
122 122
     {
123
-        if (! $this->isCachable()) {
123
+        if (!$this->isCachable()) {
124 124
             return parent::max($column);
125 125
         }
126 126
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
     public function min($column)
133 133
     {
134
-        if (! $this->isCachable()) {
134
+        if (!$this->isCachable()) {
135 135
             return parent::min($column);
136 136
         }
137 137
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
         $pageName = "page",
147 147
         $page = null
148 148
     ) {
149
-        if (! $this->isCachable()) {
149
+        if (!$this->isCachable()) {
150 150
             return parent::paginate($perPage, $columns, $pageName, $page);
151 151
         }
152 152
 
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
 
169 169
         foreach ($items as $key => $value) {
170 170
             if (is_array($value)) {
171
-                $result .= $key . $glue . $this->recursiveImplodeWithKey($value, $glue);
171
+                $result .= $key.$glue.$this->recursiveImplodeWithKey($value, $glue);
172 172
 
173 173
                 continue;
174 174
             }
175 175
 
176
-            $result .= $glue . $key . $glue . $value;
176
+            $result .= $glue.$key.$glue.$value;
177 177
         }
178 178
 
179 179
         return $result;
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
 
182 182
     public function pluck($column, $key = null)
183 183
     {
184
-        if (! $this->isCachable()) {
184
+        if (!$this->isCachable()) {
185 185
             return parent::pluck($column, $key);
186 186
         }
187 187
 
188
-        $keyDifferentiator = "-pluck_{$column}" . ($key ? "_{$key}" : "");
188
+        $keyDifferentiator = "-pluck_{$column}".($key ? "_{$key}" : "");
189 189
         $cacheKey = $this->makeCacheKey([$column], null, $keyDifferentiator);
190 190
 
191 191
         return $this->cachedValue(func_get_args(), $cacheKey);
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 
194 194
     public function sum($column)
195 195
     {
196
-        if (! $this->isCachable()) {
196
+        if (!$this->isCachable()) {
197 197
             return parent::sum($column);
198 198
         }
199 199
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 
212 212
     public function value($column)
213 213
     {
214
-        if (! $this->isCachable()) {
214
+        if (!$this->isCachable()) {
215 215
             return parent::value($column);
216 216
         }
217 217
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
         return $this->cache($cacheTags)
287 287
             ->rememberForever(
288 288
                 $hashedCacheKey,
289
-                function () use ($arguments, $cacheKey, $method) {
289
+                function() use ($arguments, $cacheKey, $method) {
290 290
                     return [
291 291
                         "key" => $cacheKey,
292 292
                         "value" => parent::{$method}(...$arguments),
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.