Passed
Push — master ( c7d0c7...a81fec )
by Mike
02:17
created
src/Traits/Cachable.php 1 patch
Spacing   +16 added lines, -16 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
         }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     {
78 78
         return "genealabs:laravel-model-caching:"
79 79
             . (config('laravel-model-caching.cache-prefix')
80
-                ? config('laravel-model-caching.cache-prefix', '') . ":"
80
+                ? config('laravel-model-caching.cache-prefix', '').":"
81 81
                 : "");
82 82
     }
83 83
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
             ->cache()
112 112
             ->get("{$cachePrefix}:{$modelClassName}-cooldown:seconds");
113 113
 
114
-        if (! $cacheCooldown) {
114
+        if (!$cacheCooldown) {
115 115
             return [null, null, null];
116 116
         }
117 117
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     {
135 135
         [$cacheCooldown, $invalidatedAt] = $this->getModelCacheCooldown($instance);
136 136
 
137
-        if (! $cacheCooldown
137
+        if (!$cacheCooldown
138 138
             || now()->diffInSeconds($invalidatedAt) < $cacheCooldown
139 139
         ) {
140 140
             return;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     {
160 160
         [$cacheCooldown, $invalidatedAt, $savedAt] = $instance->getModelCacheCooldown($instance);
161 161
 
162
-        if (! $cacheCooldown) {
162
+        if (!$cacheCooldown) {
163 163
             $instance->flushCache();
164 164
 
165 165
             return;
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
     {
179 179
         $cachePrefix = "genealabs:laravel-model-caching:"
180 180
             . (config('laravel-model-caching.cache-prefix')
181
-                ? config('laravel-model-caching.cache-prefix', '') . ":"
181
+                ? config('laravel-model-caching.cache-prefix', '').":"
182 182
                 : "");
183 183
         $modelClassName = get_class($instance);
184 184
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
185 185
 
186 186
         $instance->cache()
187
-            ->rememberForever($cacheKey, function () {
187
+            ->rememberForever($cacheKey, function() {
188 188
                 return now();
189 189
             });
190 190
     }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     public static function bootCachable()
193 193
     {
194 194
         // TODO: add for deleted,updated,etc?
195
-        static::saved(function ($instance) {
195
+        static::saved(function($instance) {
196 196
             $instance->checkCooldownAndFlushAfterPersiting($instance);
197 197
         });
198 198
     }
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
         $key = $instance->makeCacheKey();
210 210
 
211 211
         return $instance->cache($tags)
212
-            ->rememberForever($key, function () use ($columns) {
212
+            ->rememberForever($key, function() use ($columns) {
213 213
                 return parent::all($columns);
214 214
             });
215 215
     }
216 216
 
217 217
     public function newEloquentBuilder($query)
218 218
     {
219
-        if (! $this->isCachable()) {
219
+        if (!$this->isCachable()) {
220 220
             $this->isCachable = true;
221 221
 
222 222
             return new EloquentBuilder($query);
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
     public function isCachable() : bool
229 229
     {
230 230
         return $this->isCachable
231
-            && ! config('laravel-model-caching.disabled');
231
+            && !config('laravel-model-caching.disabled');
232 232
     }
233 233
 
234 234
     public function scopeWithCacheCooldownSeconds(
@@ -237,19 +237,19 @@  discard block
 block discarded – undo
237 237
     ) : EloquentBuilder {
238 238
         $cachePrefix = "genealabs:laravel-model-caching:"
239 239
             . (config('laravel-model-caching.cache-prefix')
240
-                ? config('laravel-model-caching.cache-prefix', '') . ":"
240
+                ? config('laravel-model-caching.cache-prefix', '').":"
241 241
                 : "");
242 242
         $modelClassName = get_class($this);
243 243
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:seconds";
244 244
 
245 245
         $this->cache()
246
-            ->rememberForever($cacheKey, function () use ($seconds) {
246
+            ->rememberForever($cacheKey, function() use ($seconds) {
247 247
                 return $seconds;
248 248
             });
249 249
 
250 250
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:invalidated-at";
251 251
         $this->cache()
252
-            ->rememberForever($cacheKey, function () {
252
+            ->rememberForever($cacheKey, function() {
253 253
                 return now();
254 254
             });
255 255
 
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.