Passed
Push — master ( 76cbc1...4c842a )
by Mike
02:38
created
src/CacheTags.php 1 patch
Spacing   +3 added lines, -3 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
 
@@ -63,6 +63,6 @@  discard block
 block discarded – undo
63 63
 
64 64
     protected function getTagName() : string
65 65
     {
66
-        return $this->getCachePrefix() . str_slug(get_class($this->model));
66
+        return $this->getCachePrefix().str_slug(get_class($this->model));
67 67
     }
68 68
 }
Please login to merge, or discard this patch.
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/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->getDatabaseConnectionName() . ":"
9
-            . $this->getDatabaseName() . ":"
8
+            . $this->getDatabaseConnectionName().":"
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   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
     protected function getLimitClause() : string
52 52
     {
53
-        if (! $this->query->limit) {
53
+        if (!$this->query->limit) {
54 54
             return "";
55 55
         }
56 56
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
     protected function getOffsetClause() : string
66 66
     {
67
-        if (! $this->query->offset) {
67
+        if (!$this->query->offset) {
68 68
             return "";
69 69
         }
70 70
 
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
         $orders = collect($this->query->orders);
77 77
 
78 78
         return $orders
79
-            ->reduce(function ($carry, $order) {
79
+            ->reduce(function($carry, $order) {
80 80
                 if (($order["type"] ?? "") === "Raw") {
81
-                    return $carry . "_orderByRaw_" . str_slug($order["sql"]);
81
+                    return $carry."_orderByRaw_".str_slug($order["sql"]);
82 82
                 }
83 83
 
84
-                return $carry . "_orderBy_" . $order["column"] . "_" . $order["direction"];
84
+                return $carry."_orderBy_".$order["column"]."_".$order["direction"];
85 85
             })
86 86
             ?: "";
87 87
     }
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
             return "";
93 93
         }
94 94
 
95
-        return "_" . implode("_", $columns);
95
+        return "_".implode("_", $columns);
96 96
     }
97 97
 
98 98
     protected function getTypeClause($where) : string
99 99
     {
100
-        $type =in_array($where["type"], ["In", "NotIn", "Null", "NotNull", "between"])
100
+        $type = in_array($where["type"], ["In", "NotIn", "Null", "NotNull", "between"])
101 101
             ? strtolower($where["type"])
102 102
             : strtolower($where["operator"]);
103 103
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
 
117 117
 
118
-        return "_" . $values;
118
+        return "_".$values;
119 119
     }
120 120
 
121 121
     protected function getValuesFromWhere(array $where) : string
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 
130 130
     protected function getValuesFromBindings(array $where, string $values) : string
131 131
     {
132
-        if (! $values && ($this->query->bindings["where"] ?? false)) {
132
+        if (!$values && ($this->query->bindings["where"] ?? false)) {
133 133
             $values = $this->query->bindings["where"][$this->currentBinding];
134 134
             $this->currentBinding++;
135 135
 
136 136
             if ($where["type"] === "between") {
137
-                $values .= "_" . $this->query->bindings["where"][$this->currentBinding];
137
+                $values .= "_".$this->query->bindings["where"][$this->currentBinding];
138 138
                 $this->currentBinding++;
139 139
             }
140 140
         }
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 
145 145
     protected function getWhereClauses(array $wheres = []) : string
146 146
     {
147
-        return "" . $this->getWheres($wheres)
148
-            ->reduce(function ($carry, $where) {
147
+        return "".$this->getWheres($wheres)
148
+            ->reduce(function($carry, $where) {
149 149
                 $value = $carry;
150 150
                 $value .= $this->getNestedClauses($where);
151 151
                 $value .= $this->getColumnClauses($where);
@@ -160,13 +160,13 @@  discard block
 block discarded – undo
160 160
 
161 161
     protected function getNestedClauses(array $where) : string
162 162
     {
163
-        if (! in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
163
+        if (!in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
164 164
             return "";
165 165
         }
166 166
 
167 167
         $this->currentBinding++;
168 168
 
169
-        return "-" . strtolower($where["type"]) . $this->getWhereClauses($where["query"]->wheres);
169
+        return "-".strtolower($where["type"]).$this->getWhereClauses($where["query"]->wheres);
170 170
     }
171 171
 
172 172
     protected function getColumnClauses(array $where) : string
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
     protected function getInClauses(array $where) : string
184 184
     {
185
-        if (! in_array($where["type"], ["In"])) {
185
+        if (!in_array($where["type"], ["In"])) {
186 186
             return "";
187 187
         }
188 188
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 
195 195
     protected function getNotInClauses(array $where) : string
196 196
     {
197
-        if (! in_array($where["type"], ["NotIn"])) {
197
+        if (!in_array($where["type"], ["NotIn"])) {
198 198
             return "";
199 199
         }
200 200
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
                 continue;
216 216
             }
217 217
 
218
-            $result .= $glue . $value;
218
+            $result .= $glue.$value;
219 219
         }
220 220
 
221 221
         return $result;
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
         $clause = "_{$where["boolean"]}";
232 232
 
233 233
         while (count($queryParts) > 1) {
234
-            $clause .= "_" . array_shift($queryParts);
234
+            $clause .= "_".array_shift($queryParts);
235 235
             $clause .= $this->query->bindings["where"][$this->currentBinding];
236 236
             $this->currentBinding++;
237 237
         }
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
         $lastPart = array_shift($queryParts);
240 240
 
241 241
         if ($lastPart) {
242
-            $clause .= "_" . $lastPart;
242
+            $clause .= "_".$lastPart;
243 243
         }
244 244
 
245
-        return "-" . str_replace(" ", "_", $clause);
245
+        return "-".str_replace(" ", "_", $clause);
246 246
     }
247 247
 
248 248
     protected function getOtherClauses(array $where) : string
@@ -276,6 +276,6 @@  discard block
 block discarded – undo
276 276
             return "";
277 277
         }
278 278
 
279
-        return "-" . implode("-", $eagerLoads->keys()->toArray());
279
+        return "-".implode("-", $eagerLoads->keys()->toArray());
280 280
     }
281 281
 }
Please login to merge, or discard this patch.
src/Traits/Caching.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
             $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
50 50
 
51 51
             $this->cache()
52
-                ->rememberForever($cacheKey, function () {
52
+                ->rememberForever($cacheKey, function() {
53 53
                     return (new Carbon)->now();
54 54
                 });
55 55
         }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     {
60 60
         return "genealabs:laravel-model-caching:"
61 61
             . (config('laravel-model-caching.cache-prefix')
62
-                ? config('laravel-model-caching.cache-prefix', '') . ":"
62
+                ? config('laravel-model-caching.cache-prefix', '').":"
63 63
                 : "");
64 64
     }
65 65
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
         [$cacheCooldown, $invalidatedAt, $savedAt] = $this
96 96
             ->getCacheCooldownDetails($instance, $cachePrefix, $modelClassName);
97 97
 
98
-        if (! $cacheCooldown || $cacheCooldown === 0) {
98
+        if (!$cacheCooldown || $cacheCooldown === 0) {
99 99
             return [null, null, null];
100 100
         }
101 101
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
     {
129 129
         [$cacheCooldown, $invalidatedAt] = $this->getModelCacheCooldown($instance);
130 130
 
131
-        if (! $cacheCooldown
131
+        if (!$cacheCooldown
132 132
             || (new Carbon)->now()->diffInSeconds($invalidatedAt) < $cacheCooldown
133 133
         ) {
134 134
             return;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     {
154 154
         [$cacheCooldown, $invalidatedAt] = $instance->getModelCacheCooldown($instance);
155 155
 
156
-        if (! $cacheCooldown) {
156
+        if (!$cacheCooldown) {
157 157
             $instance->flushCache();
158 158
 
159 159
             return;
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
     public function isCachable() : bool
170 170
     {
171 171
         return $this->isCachable
172
-            && ! config('laravel-model-caching.disabled');
172
+            && !config('laravel-model-caching.disabled');
173 173
     }
174 174
 
175 175
     protected function setCacheCooldownSavedAtTimestamp(Model $instance)
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
180 180
 
181 181
         $instance->cache()
182
-            ->rememberForever($cacheKey, function () {
182
+            ->rememberForever($cacheKey, function() {
183 183
                 return (new Carbon)->now();
184 184
             });
185 185
     }
Please login to merge, or discard this patch.
src/Traits/ModelCaching.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -18,30 +18,30 @@  discard block
 block discarded – undo
18 18
         $key = $instance->makeCacheKey();
19 19
 
20 20
         return $instance->cache($tags)
21
-            ->rememberForever($key, function () use ($columns) {
21
+            ->rememberForever($key, function() use ($columns) {
22 22
                 return parent::all($columns);
23 23
             });
24 24
     }
25 25
 
26 26
     public static function bootCachable()
27 27
     {
28
-        static::deleted(function ($instance) {
28
+        static::deleted(function($instance) {
29 29
             $instance->checkCooldownAndFlushAfterPersiting($instance);
30 30
         });
31 31
 
32
-        static::saved(function ($instance) {
32
+        static::saved(function($instance) {
33 33
             $instance->checkCooldownAndFlushAfterPersiting($instance);
34 34
         });
35 35
 
36
-        static::pivotAttached(function ($instance) {
36
+        static::pivotAttached(function($instance) {
37 37
             $instance->checkCooldownAndFlushAfterPersiting($instance);
38 38
         });
39 39
 
40
-        static::pivotDetached(function ($instance) {
40
+        static::pivotDetached(function($instance) {
41 41
             $instance->checkCooldownAndFlushAfterPersiting($instance);
42 42
         });
43 43
 
44
-        static::pivotUpdated(function ($instance) {
44
+        static::pivotUpdated(function($instance) {
45 45
             $instance->checkCooldownAndFlushAfterPersiting($instance);
46 46
         });
47 47
     }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
     public function newEloquentBuilder($query)
59 59
     {
60
-        if (! $this->isCachable()) {
60
+        if (!$this->isCachable()) {
61 61
             $this->isCachable = true;
62 62
 
63 63
             return new EloquentBuilder($query);
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:seconds";
85 85
 
86 86
         $this->cache()
87
-            ->rememberForever($cacheKey, function () use ($seconds) {
87
+            ->rememberForever($cacheKey, function() use ($seconds) {
88 88
                 return $seconds;
89 89
             });
90 90
 
91 91
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:invalidated-at";
92 92
         $this->cache()
93
-            ->rememberForever($cacheKey, function () {
93
+            ->rememberForever($cacheKey, function() {
94 94
                 return (new Carbon)->now();
95 95
             });
96 96
 
Please login to merge, or discard this patch.
src/CachedBuilder.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
     public function avg($column)
17 17
     {
18
-        if (! $this->isCachable()) {
18
+        if (!$this->isCachable()) {
19 19
             return parent::avg($column);
20 20
         }
21 21
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
     public function count($columns = "*")
28 28
     {
29
-        if (! $this->isCachable()) {
29
+        if (!$this->isCachable()) {
30 30
             return parent::count($columns);
31 31
         }
32 32
 
@@ -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
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 
61 61
     public function first($columns = ["*"])
62 62
     {
63
-        if (! $this->isCachable()) {
63
+        if (!$this->isCachable()) {
64 64
             return parent::first($columns);
65 65
         }
66 66
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 
72 72
     public function get($columns = ["*"])
73 73
     {
74
-        if (! $this->isCachable()) {
74
+        if (!$this->isCachable()) {
75 75
             return parent::get($columns);
76 76
         }
77 77
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
     public function max($column)
98 98
     {
99
-        if (! $this->isCachable()) {
99
+        if (!$this->isCachable()) {
100 100
             return parent::max($column);
101 101
         }
102 102
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
     public function min($column)
109 109
     {
110
-        if (! $this->isCachable()) {
110
+        if (!$this->isCachable()) {
111 111
             return parent::min($column);
112 112
         }
113 113
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         $pageName = "page",
123 123
         $page = null
124 124
     ) {
125
-        if (! $this->isCachable()) {
125
+        if (!$this->isCachable()) {
126 126
             return parent::paginate($perPage, $columns, $pageName, $page);
127 127
         }
128 128
 
@@ -144,12 +144,12 @@  discard block
 block discarded – undo
144 144
 
145 145
         foreach ($items as $key => $value) {
146 146
             if (is_array($value)) {
147
-                $result .= $key . $glue . $this->recursiveImplode($value, $glue);
147
+                $result .= $key.$glue.$this->recursiveImplode($value, $glue);
148 148
 
149 149
                 continue;
150 150
             }
151 151
 
152
-            $result .= $glue . $key . $glue . $value;
152
+            $result .= $glue.$key.$glue.$value;
153 153
         }
154 154
 
155 155
         return $result;
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
 
158 158
     public function pluck($column, $key = null)
159 159
     {
160
-        if (! $this->isCachable()) {
160
+        if (!$this->isCachable()) {
161 161
             return parent::pluck($column, $key);
162 162
         }
163 163
 
164
-        $keyDifferentiator = "-pluck_{$column}" . ($key ? "_{$key}" : "");
164
+        $keyDifferentiator = "-pluck_{$column}".($key ? "_{$key}" : "");
165 165
         $cacheKey = $this->makeCacheKey([$column], null, $keyDifferentiator);
166 166
 
167 167
         return $this->cachedValue(func_get_args(), $cacheKey);
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
     public function sum($column)
171 171
     {
172
-        if (! $this->isCachable()) {
172
+        if (!$this->isCachable()) {
173 173
             return parent::sum($column);
174 174
         }
175 175
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 
188 188
     public function value($column)
189 189
     {
190
-        if (! $this->isCachable()) {
190
+        if (!$this->isCachable()) {
191 191
             return parent::value($column);
192 192
         }
193 193
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         return $this->cache($cacheTags)
257 257
             ->rememberForever(
258 258
                 $hashedCacheKey,
259
-                function () use ($arguments, $cacheKey, $method) {
259
+                function() use ($arguments, $cacheKey, $method) {
260 260
                     return [
261 261
                         "key" => $cacheKey,
262 262
                         "value" => parent::{$method}(...$arguments),
Please login to merge, or discard this patch.