Passed
Push — master ( d182c1...749c7a )
by Mike
02:50
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
             return $this->flushEntireCache();
16 16
         }
17 17
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         $usesCachableTrait = collect(class_uses($model))
36 36
             ->contains("GeneaLabs\LaravelModelCaching\Traits\Cachable");
37 37
 
38
-        if (! $usesCachableTrait) {
38
+        if (!$usesCachableTrait) {
39 39
             $this->error("'{$option}' is not an instance of CachedModel.");
40 40
             $this->line("Only CachedModel instances can be flushed.");
41 41
 
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
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         $values = $this->getValuesFromWhere($where);
118 118
         $values = $this->getValuesFromBindings($values);
119 119
 
120
-        return "_" . $values;
120
+        return "_".$values;
121 121
     }
122 122
 
123 123
     protected function getValuesFromWhere(array $where) : string
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 
130 130
     protected function getValuesFromBindings(string $values) : string
131 131
     {
132
-        if (! $values && $this->query->bindings["where"] ?? false) {
132
+        if (!$values && $this->query->bindings["where"] ?? false) {
133 133
             $values = implode("_", $this->query->bindings["where"]);
134 134
         }
135 135
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     protected function getWhereClauses(array $wheres = []) : string
140 140
     {
141 141
         return $this->getWheres($wheres)
142
-            ->reduce(function ($carry, $where) {
142
+            ->reduce(function($carry, $where) {
143 143
                 $value = $this->getNestedClauses($where);
144 144
                 $value .= $this->getColumnClauses($where);
145 145
                 $value .= $this->getRawClauses($where);
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 
153 153
     protected function getNestedClauses(array $where) : string
154 154
     {
155
-        if (! in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
155
+        if (!in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
156 156
             return "";
157 157
         }
158 158
 
159
-        return "_" . strtolower($where["type"]) . $this->getWhereClauses($where["query"]->wheres);
159
+        return "_".strtolower($where["type"]).$this->getWhereClauses($where["query"]->wheres);
160 160
     }
161 161
 
162 162
     protected function getColumnClauses(array $where) : string
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
             return "";
175 175
         }
176 176
 
177
-        return "_{$where["boolean"]}_" . str_slug($where["sql"]);
177
+        return "_{$where["boolean"]}_".str_slug($where["sql"]);
178 178
     }
179 179
 
180 180
     protected function getOtherClauses(array $where, string $carry = null) : string
@@ -208,6 +208,6 @@  discard block
 block discarded – undo
208 208
             return "";
209 209
         }
210 210
 
211
-        return "-" . implode("-", $eagerLoads->keys()->toArray());
211
+        return "-".implode("-", $eagerLoads->keys()->toArray());
212 212
     }
213 213
 }
Please login to merge, or discard this patch.
src/CachedBuilder.php 1 patch
Spacing   +13 added lines, -13 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
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function find($id, $columns = ["*"])
47 47
     {
48
-        if (! $this->isCachable()) {
48
+        if (!$this->isCachable()) {
49 49
             return parent::find($id, $columns);
50 50
         }
51 51
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
     public function first($columns = ["*"])
58 58
     {
59
-        if (! $this->isCachable()) {
59
+        if (!$this->isCachable()) {
60 60
             return parent::first($columns);
61 61
         }
62 62
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
     public function get($columns = ["*"])
69 69
     {
70
-        if (! $this->isCachable()) {
70
+        if (!$this->isCachable()) {
71 71
             return parent::get($columns);
72 72
         }
73 73
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
     public function max($column)
80 80
     {
81
-        if (! $this->isCachable()) {
81
+        if (!$this->isCachable()) {
82 82
             return parent::max($column);
83 83
         }
84 84
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
     public function min($column)
91 91
     {
92
-        if (! $this->isCachable()) {
92
+        if (!$this->isCachable()) {
93 93
             return parent::min($column);
94 94
         }
95 95
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         $pageName = "page",
105 105
         $page = null
106 106
     ) {
107
-        if (! $this->isCachable()) {
107
+        if (!$this->isCachable()) {
108 108
             return parent::paginate($perPage, $columns, $pageName, $page);
109 109
         }
110 110
 
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 
117 117
     public function pluck($column, $key = null)
118 118
     {
119
-        if (! $this->isCachable()) {
119
+        if (!$this->isCachable()) {
120 120
             return parent::pluck($column, $key);
121 121
         }
122 122
 
123
-        $keyDifferentiator = "-pluck_{$column}" . ($key ? "_{$key}" : "");
123
+        $keyDifferentiator = "-pluck_{$column}".($key ? "_{$key}" : "");
124 124
         $cacheKey = $this->makeCacheKey([$column], null, $keyDifferentiator);
125 125
 
126 126
         return $this->cachedValue(func_get_args(), $cacheKey);
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 
129 129
     public function sum($column)
130 130
     {
131
-        if (! $this->isCachable()) {
131
+        if (!$this->isCachable()) {
132 132
             return parent::sum($column);
133 133
         }
134 134
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
     public function value($column)
141 141
     {
142
-        if (! $this->isCachable()) {
142
+        if (!$this->isCachable()) {
143 143
             return parent::value($column);
144 144
         }
145 145
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
         return $this->cache($cacheTags)
209 209
             ->rememberForever(
210 210
                 $hashedCacheKey,
211
-                function () use ($arguments, $cacheKey, $method) {
211
+                function() use ($arguments, $cacheKey, $method) {
212 212
                     return [
213 213
                         "key" => $cacheKey,
214 214
                         "value" => parent::{$method}(...$arguments),
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,7 +27,7 @@  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 = $this->getRelation($relationName);
32 32
 
33 33
                 return $this->getCachePrefix()
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     protected function getRelation(string $relationName) : Relation
53 53
     {
54 54
         return collect(explode('.', $relationName))
55
-            ->reduce(function ($carry, $name) {
55
+            ->reduce(function($carry, $name) {
56 56
                 $carry = $carry ?: $this->model;
57 57
                 $carry = $this->getRelatedModel($carry);
58 58
 
@@ -62,6 +62,6 @@  discard block
 block discarded – undo
62 62
 
63 63
     protected function getTagName() : string
64 64
     {
65
-        return $this->getCachePrefix() . str_slug(get_class($this->model));
65
+        return $this->getCachePrefix().str_slug(get_class($this->model));
66 66
     }
67 67
 }
Please login to merge, or discard this patch.
src/Traits/Cachable.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
52 52
 
53 53
             $this->cache()
54
-                ->rememberForever($cacheKey, function () {
54
+                ->rememberForever($cacheKey, function() {
55 55
                     return now();
56 56
                 });
57 57
         }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     {
62 62
         return "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
     }
67 67
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
         [$cacheCooldown, $invalidatedAt, $savedAt] = $this
94 94
             ->getCacheCooldownDetails($instance, $cachePrefix, $modelClassName);
95 95
 
96
-        if (! $cacheCooldown || $cacheCooldown === 0) {
96
+        if (!$cacheCooldown || $cacheCooldown === 0) {
97 97
             return [null, null, null];
98 98
         }
99 99
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     {
127 127
         [$cacheCooldown, $invalidatedAt] = $this->getModelCacheCooldown($instance);
128 128
 
129
-        if (! $cacheCooldown
129
+        if (!$cacheCooldown
130 130
             || now()->diffInSeconds($invalidatedAt) < $cacheCooldown
131 131
         ) {
132 132
             return;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     {
152 152
         [$cacheCooldown, $invalidatedAt] = $instance->getModelCacheCooldown($instance);
153 153
 
154
-        if (! $cacheCooldown) {
154
+        if (!$cacheCooldown) {
155 155
             $instance->flushCache();
156 156
 
157 157
             return;
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
172 172
 
173 173
         $instance->cache()
174
-            ->rememberForever($cacheKey, function () {
174
+            ->rememberForever($cacheKey, function() {
175 175
                 return now();
176 176
             });
177 177
     }
178 178
 
179 179
     public static function bootCachable()
180 180
     {
181
-        static::saved(function ($instance) {
181
+        static::saved(function($instance) {
182 182
             $instance->checkCooldownAndFlushAfterPersiting($instance);
183 183
         });
184 184
     }
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
         $key = $instance->makeCacheKey();
196 196
 
197 197
         return $instance->cache($tags)
198
-            ->rememberForever($key, function () use ($columns) {
198
+            ->rememberForever($key, function() use ($columns) {
199 199
                 return parent::all($columns);
200 200
             });
201 201
     }
202 202
 
203 203
     public function newEloquentBuilder($query)
204 204
     {
205
-        if (! $this->isCachable()) {
205
+        if (!$this->isCachable()) {
206 206
             $this->isCachable = true;
207 207
 
208 208
             return new EloquentBuilder($query);
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
     public function isCachable() : bool
215 215
     {
216 216
         return $this->isCachable
217
-            && ! config('laravel-model-caching.disabled');
217
+            && !config('laravel-model-caching.disabled');
218 218
     }
219 219
 
220 220
     public function scopeWithCacheCooldownSeconds(
@@ -226,13 +226,13 @@  discard block
 block discarded – undo
226 226
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:seconds";
227 227
 
228 228
         $this->cache()
229
-            ->rememberForever($cacheKey, function () use ($seconds) {
229
+            ->rememberForever($cacheKey, function() use ($seconds) {
230 230
                 return $seconds;
231 231
             });
232 232
 
233 233
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:invalidated-at";
234 234
         $this->cache()
235
-            ->rememberForever($cacheKey, function () {
235
+            ->rememberForever($cacheKey, function() {
236 236
                 return now();
237 237
             });
238 238
 
Please login to merge, or discard this patch.