Passed
Push — master ( 3d59b3...73e21c )
by Mike
02:25
created
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(Flush::class);
15 15
     }
Please login to merge, or discard this patch.
src/Console/Commands/Flush.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
     {
12 12
         $option = $this->option('model');
13 13
 
14
-        if (! $option) {
14
+        if (!$option) {
15 15
             cache()
16 16
                 ->store(config('laravel-model-caching.store'))
17 17
                 ->flush();
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         $usesCachableTrait = collect(class_uses($model))
26 26
             ->contains("GeneaLabs\LaravelModelCaching\Traits\Cachable");
27 27
 
28
-        if (! $usesCachableTrait) {
28
+        if (!$usesCachableTrait) {
29 29
             $this->error("'{$option}' is not an instance of CachedModel.");
30 30
             $this->line("Only CachedModel instances can be flushed.");
31 31
 
Please login to merge, or discard this patch.
src/CacheTags.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     {
20 20
         return "genealabs:laravel-model-caching:"
21 21
             . (config('laravel-model-caching.cache-prefix')
22
-                ? config('laravel-model-caching.cache-prefix', '') . ":"
22
+                ? config('laravel-model-caching.cache-prefix', '').":"
23 23
                 : "");
24 24
     }
25 25
 
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
     {
28 28
         $tags = collect($this->eagerLoad)
29 29
             ->keys()
30
-            ->map(function ($relationName) {
30
+            ->map(function($relationName) {
31 31
                 $relation = collect(explode('.', $relationName))
32
-                    ->reduce(function ($carry, $name) {
33
-                        if (! $carry) {
32
+                    ->reduce(function($carry, $name) {
33
+                        if (!$carry) {
34 34
                             $carry = $this->model;
35 35
                         }
36 36
 
Please login to merge, or discard this patch.
src/CacheKey.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     {
15 15
         return "genealabs:laravel-model-caching:"
16 16
             . (config("laravel-model-caching.cache-prefix")
17
-                ? config("laravel-model-caching.cache-prefix", "") . ":"
17
+                ? config("laravel-model-caching.cache-prefix", "").":"
18 18
                 : "");
19 19
     }
20 20
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
     protected function getLimitClause() : string
56 56
     {
57
-        if (! $this->query->limit) {
57
+        if (!$this->query->limit) {
58 58
             return "";
59 59
         }
60 60
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
     protected function getOffsetClause() : string
70 70
     {
71
-        if (! $this->query->offset) {
71
+        if (!$this->query->offset) {
72 72
             return "";
73 73
         }
74 74
 
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
         $orders = collect($this->query->orders);
81 81
 
82 82
         return $orders
83
-            ->reduce(function ($carry, $order) {
83
+            ->reduce(function($carry, $order) {
84 84
                 if (($order["type"] ?? "") === "Raw") {
85
-                    return $carry . "_orderByRaw_" . str_slug($order["sql"]);
85
+                    return $carry."_orderByRaw_".str_slug($order["sql"]);
86 86
                 }
87 87
 
88
-                return $carry . "_orderBy_" . $order["column"] . "_" . $order["direction"];
88
+                return $carry."_orderBy_".$order["column"]."_".$order["direction"];
89 89
             })
90 90
             ?: "";
91 91
     }
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
             return "";
97 97
         }
98 98
 
99
-        return "_" . implode("_", $columns);
99
+        return "_".implode("_", $columns);
100 100
     }
101 101
 
102 102
     protected function getTypeClause($where) : string
103 103
     {
104
-        $type =in_array($where["type"], ["In", "NotIn", "Null", "NotNull", "between"])
104
+        $type = in_array($where["type"], ["In", "NotIn", "Null", "NotNull", "between"])
105 105
             ? strtolower($where["type"])
106 106
             : strtolower($where["operator"]);
107 107
 
@@ -118,17 +118,17 @@  discard block
 block discarded – undo
118 118
             ? implode("_", $where["values"])
119 119
             : "";
120 120
 
121
-        if (! $values && $this->query->bindings["where"] ?? false) {
121
+        if (!$values && $this->query->bindings["where"] ?? false) {
122 122
             $values = implode("_", $this->query->bindings["where"]);
123 123
         }
124 124
 
125
-        return "_" . $values;
125
+        return "_".$values;
126 126
     }
127 127
 
128 128
     protected function getWhereClauses(array $wheres = []) : string
129 129
     {
130 130
         return $this->getWheres($wheres)
131
-            ->reduce(function ($carry, $where) {
131
+            ->reduce(function($carry, $where) {
132 132
                 $value = $this->getNestedClauses($where);
133 133
                 $value .= $this->getColumnClauses($where);
134 134
                 $value .= $this->getRawClauses($where);
@@ -141,11 +141,11 @@  discard block
 block discarded – undo
141 141
 
142 142
     protected function getNestedClauses(array $where) : string
143 143
     {
144
-        if (! in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
144
+        if (!in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
145 145
             return "";
146 146
         }
147 147
 
148
-        return "_" . strtolower($where["type"]) . $this->getWhereClauses($where["query"]->wheres);
148
+        return "_".strtolower($where["type"]).$this->getWhereClauses($where["query"]->wheres);
149 149
     }
150 150
 
151 151
     protected function getColumnClauses(array $where) : string
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
             return "";
164 164
         }
165 165
 
166
-        return "_{$where["boolean"]}_" . str_slug($where["sql"]);
166
+        return "_{$where["boolean"]}_".str_slug($where["sql"]);
167 167
     }
168 168
 
169 169
     protected function getOtherClauses(array $where, string $carry = null) : string
@@ -197,6 +197,6 @@  discard block
 block discarded – undo
197 197
             return "";
198 198
         }
199 199
 
200
-        return "-" . implode("-", $eagerLoads->keys()->toArray());
200
+        return "-".implode("-", $eagerLoads->keys()->toArray());
201 201
     }
202 202
 }
Please login to merge, or discard this patch.
src/Traits/Cachable.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         $usesCachableTrait = collect(class_uses($this))
35 35
             ->contains("GeneaLabs\LaravelModelCaching\Traits\Cachable");
36 36
 
37
-        if (! $usesCachableTrait) {
37
+        if (!$usesCachableTrait) {
38 38
             array_push($tags, str_slug(get_called_class()));
39 39
         }
40 40
 
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
         if ($cacheCooldown) {
62 62
             $cachePrefix = "genealabs:laravel-model-caching:"
63 63
                 . (config('laravel-model-caching.cache-prefix')
64
-                    ? config('laravel-model-caching.cache-prefix', '') . ":"
64
+                    ? config('laravel-model-caching.cache-prefix', '').":"
65 65
                     : "");
66 66
             $modelClassName = get_class($this);
67 67
             $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
68 68
 
69 69
             $this->cache()
70
-                ->rememberForever($cacheKey, function () {
70
+                ->rememberForever($cacheKey, function() {
71 71
                     return now();
72 72
                 });
73 73
         }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     {
99 99
         $cachePrefix = "genealabs:laravel-model-caching:"
100 100
             . (config('laravel-model-caching.cache-prefix')
101
-                ? config('laravel-model-caching.cache-prefix', '') . ":"
101
+                ? config('laravel-model-caching.cache-prefix', '').":"
102 102
                 : "");
103 103
         $modelClassName = get_class($instance);
104 104
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             ->cache()
107 107
             ->get("{$cachePrefix}:{$modelClassName}-cooldown:seconds");
108 108
 
109
-        if (! $cacheCooldown) {
109
+        if (!$cacheCooldown) {
110 110
             return [null, null, null];
111 111
         }
112 112
 
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
     {
130 130
         [$cacheCooldown, $invalidatedAt] = $this->getModelCacheCooldown($instance);
131 131
 
132
-        if (! $cacheCooldown) {
132
+        if (!$cacheCooldown) {
133 133
             return;
134 134
         }
135 135
 
136 136
         if (now()->diffInSeconds($invalidatedAt) >= $cacheCooldown) {
137 137
             $cachePrefix = "genealabs:laravel-model-caching:"
138 138
                 . (config('laravel-model-caching.cache-prefix')
139
-                    ? config('laravel-model-caching.cache-prefix', '') . ":"
139
+                    ? config('laravel-model-caching.cache-prefix', '').":"
140 140
                     : "");
141 141
             $modelClassName = get_class($instance);
142 142
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     {
158 158
         [$cacheCooldown, $invalidatedAt, $savedAt] = $instance->getModelCacheCooldown($instance);
159 159
 
160
-        if (! $cacheCooldown) {
160
+        if (!$cacheCooldown) {
161 161
             $instance->flushCache();
162 162
 
163 163
             return;
@@ -166,13 +166,13 @@  discard block
 block discarded – undo
166 166
         if ($cacheCooldown) {
167 167
             $cachePrefix = "genealabs:laravel-model-caching:"
168 168
                 . (config('laravel-model-caching.cache-prefix')
169
-                    ? config('laravel-model-caching.cache-prefix', '') . ":"
169
+                    ? config('laravel-model-caching.cache-prefix', '').":"
170 170
                     : "");
171 171
             $modelClassName = get_class($instance);
172 172
             $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
173 173
 
174 174
             $instance->cache()
175
-                ->rememberForever($cacheKey, function () {
175
+                ->rememberForever($cacheKey, function() {
176 176
                     return now();
177 177
                 });
178 178
         }
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
     public static function bootCachable()
188 188
     {
189 189
         // TODO: add for deleted,updated,etc?
190
-        static::saved(function ($instance) {
190
+        static::saved(function($instance) {
191 191
             $instance->checkCooldownAndFlushAfterPersiting($instance);
192 192
         });
193 193
     }
@@ -204,14 +204,14 @@  discard block
 block discarded – undo
204 204
         $key = $instance->makeCacheKey();
205 205
 
206 206
         return $instance->cache($tags)
207
-            ->rememberForever($key, function () use ($columns) {
207
+            ->rememberForever($key, function() use ($columns) {
208 208
                 return parent::all($columns);
209 209
             });
210 210
     }
211 211
 
212 212
     public function newEloquentBuilder($query)
213 213
     {
214
-        if (! $this->isCachable()) {
214
+        if (!$this->isCachable()) {
215 215
             $this->isCachable = true;
216 216
 
217 217
             return new EloquentBuilder($query);
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
     public function isCachable() : bool
224 224
     {
225 225
         return $this->isCachable
226
-            && ! config('laravel-model-caching.disabled');
226
+            && !config('laravel-model-caching.disabled');
227 227
     }
228 228
 
229 229
     public function scopeWithCacheCooldownSeconds(
@@ -232,19 +232,19 @@  discard block
 block discarded – undo
232 232
     ) : EloquentBuilder {
233 233
         $cachePrefix = "genealabs:laravel-model-caching:"
234 234
             . (config('laravel-model-caching.cache-prefix')
235
-                ? config('laravel-model-caching.cache-prefix', '') . ":"
235
+                ? config('laravel-model-caching.cache-prefix', '').":"
236 236
                 : "");
237 237
         $modelClassName = get_class($this);
238 238
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:seconds";
239 239
 
240 240
         $this->cache()
241
-            ->rememberForever($cacheKey, function () use ($seconds) {
241
+            ->rememberForever($cacheKey, function() use ($seconds) {
242 242
                 return $seconds;
243 243
             });
244 244
 
245 245
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:invalidated-at";
246 246
         $this->cache()
247
-            ->rememberForever($cacheKey, function () use ($seconds) {
247
+            ->rememberForever($cacheKey, function() use ($seconds) {
248 248
                 return now();
249 249
             });
250 250
 
Please login to merge, or discard this patch.
src/CachedBuilder.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
     public function avg($column)
14 14
     {
15
-        if (! $this->isCachable()) {
15
+        if (!$this->isCachable()) {
16 16
             return parent::avg($column);
17 17
         }
18 18
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
     public function count($columns = ["*"])
25 25
     {
26
-        if (! $this->isCachable()) {
26
+        if (!$this->isCachable()) {
27 27
             return parent::count($columns);
28 28
         }
29 29
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
     public function cursor()
36 36
     {
37
-        if (! $this->isCachable()) {
37
+        if (!$this->isCachable()) {
38 38
             return collect(parent::cursor());
39 39
         }
40 40
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function find($id, $columns = ["*"])
58 58
     {
59
-        if (! $this->isCachable()) {
59
+        if (!$this->isCachable()) {
60 60
             return parent::find($id, $columns);
61 61
         }
62 62
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
     public function first($columns = ["*"])
69 69
     {
70
-        if (! $this->isCachable()) {
70
+        if (!$this->isCachable()) {
71 71
             return parent::first($columns);
72 72
         }
73 73
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
     public function get($columns = ["*"])
80 80
     {
81
-        if (! $this->isCachable()) {
81
+        if (!$this->isCachable()) {
82 82
             return parent::get($columns);
83 83
         }
84 84
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
     public function max($column)
91 91
     {
92
-        if (! $this->isCachable()) {
92
+        if (!$this->isCachable()) {
93 93
             return parent::max($column);
94 94
         }
95 95
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 
101 101
     public function min($column)
102 102
     {
103
-        if (! $this->isCachable()) {
103
+        if (!$this->isCachable()) {
104 104
             return parent::min($column);
105 105
         }
106 106
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         $pageName = "page",
116 116
         $page = null
117 117
     ) {
118
-        if (! $this->isCachable()) {
118
+        if (!$this->isCachable()) {
119 119
             return parent::paginate($perPage, $columns, $pageName, $page);
120 120
         }
121 121
 
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 
128 128
     public function pluck($column, $key = null)
129 129
     {
130
-        if (! $this->isCachable()) {
130
+        if (!$this->isCachable()) {
131 131
             return parent::pluck($column, $key);
132 132
         }
133 133
 
134
-        $keyDifferentiator = "-pluck_{$column}" . ($key ? "_{$key}" : "");
134
+        $keyDifferentiator = "-pluck_{$column}".($key ? "_{$key}" : "");
135 135
         $cacheKey = $this->makeCacheKey([$column], null, $keyDifferentiator);
136 136
 
137 137
         return $this->cachedValue(func_get_args(), $cacheKey);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
     public function sum($column)
141 141
     {
142
-        if (! $this->isCachable()) {
142
+        if (!$this->isCachable()) {
143 143
             return parent::sum($column);
144 144
         }
145 145
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
     public function value($column)
152 152
     {
153
-        if (! $this->isCachable()) {
153
+        if (!$this->isCachable()) {
154 154
             return parent::value($column);
155 155
         }
156 156
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         return $this->cache($cacheTags)
220 220
             ->rememberForever(
221 221
                 $hashedCacheKey,
222
-                function () use ($arguments, $cacheKey, $method) {
222
+                function() use ($arguments, $cacheKey, $method) {
223 223
                     return [
224 224
                         "key" => $cacheKey,
225 225
                         "value" => parent::{$method}(...$arguments),
Please login to merge, or discard this patch.