Passed
Push — master ( 3e99b8...1655e8 )
by Mike
06:02 queued 11s
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/Traits/Caching.php 1 patch
Spacing   +8 added lines, -8 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
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
     public function getModelCacheCooldown(Model $instance) : array
95 95
     {
96
-        if (! $instance->cacheCooldownSeconds) {
96
+        if (!$instance->cacheCooldownSeconds) {
97 97
             return [null, null, null];
98 98
         }
99 99
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         [$cacheCooldown, $invalidatedAt, $savedAt] = $this
103 103
             ->getCacheCooldownDetails($instance, $cachePrefix, $modelClassName);
104 104
 
105
-        if (! $cacheCooldown || $cacheCooldown === 0) {
105
+        if (!$cacheCooldown || $cacheCooldown === 0) {
106 106
             return [null, null, null];
107 107
         }
108 108
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     {
132 132
         [$cacheCooldown, $invalidatedAt] = $this->getModelCacheCooldown($instance);
133 133
 
134
-        if (! $cacheCooldown
134
+        if (!$cacheCooldown
135 135
             || (new Carbon)->now()->diffInSeconds($invalidatedAt) < $cacheCooldown
136 136
         ) {
137 137
             return;
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     {
157 157
         [$cacheCooldown, $invalidatedAt] = $instance->getModelCacheCooldown($instance);
158 158
 
159
-        if (! $cacheCooldown) {
159
+        if (!$cacheCooldown) {
160 160
             $instance->flushCache();
161 161
 
162 162
             return;
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     public function isCachable() : bool
173 173
     {
174 174
         return $this->isCachable
175
-            && ! config('laravel-model-caching.disabled');
175
+            && !config('laravel-model-caching.disabled');
176 176
     }
177 177
 
178 178
     protected function setCacheCooldownSavedAtTimestamp(Model $instance)
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
183 183
 
184 184
         $instance->cache()
185
-            ->rememberForever($cacheKey, function () {
185
+            ->rememberForever($cacheKey, function() {
186 186
                 return (new Carbon)->now();
187 187
             });
188 188
     }
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
@@ -20,22 +20,22 @@  discard block
 block discarded – undo
20 20
         $key = $instance->makeCacheKey();
21 21
 
22 22
         return $instance->cache($tags)
23
-            ->rememberForever($key, function () use ($columns) {
23
+            ->rememberForever($key, function() use ($columns) {
24 24
                 return parent::all($columns);
25 25
             });
26 26
     }
27 27
 
28 28
     public static function bootCachable()
29 29
     {
30
-        static::created(function ($instance) {
30
+        static::created(function($instance) {
31 31
             $instance->checkCooldownAndFlushAfterPersisting($instance);
32 32
         });
33 33
 
34
-        static::deleted(function ($instance) {
34
+        static::deleted(function($instance) {
35 35
             $instance->checkCooldownAndFlushAfterPersisting($instance);
36 36
         });
37 37
 
38
-        static::saved(function ($instance) {
38
+        static::saved(function($instance) {
39 39
             $instance->checkCooldownAndFlushAfterPersisting($instance);
40 40
         });
41 41
 
@@ -44,15 +44,15 @@  discard block
 block discarded – undo
44 44
         //     $instance->checkCooldownAndFlushAfterPersisting($instance);
45 45
         // });
46 46
 
47
-        static::pivotAttached(function ($instance) {
47
+        static::pivotAttached(function($instance) {
48 48
             $instance->checkCooldownAndFlushAfterPersisting($instance);
49 49
         });
50 50
 
51
-        static::pivotDetached(function ($instance) {
51
+        static::pivotDetached(function($instance) {
52 52
             $instance->checkCooldownAndFlushAfterPersisting($instance);
53 53
         });
54 54
 
55
-        static::pivotUpdated(function ($instance) {
55
+        static::pivotUpdated(function($instance) {
56 56
             $instance->checkCooldownAndFlushAfterPersisting($instance);
57 57
         });
58 58
     }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
     public function newEloquentBuilder($query)
70 70
     {
71
-        if (! $this->isCachable()) {
71
+        if (!$this->isCachable()) {
72 72
             $this->isCachable = false;
73 73
 
74 74
             return new EloquentBuilder($query);
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         EloquentBuilder $query,
91 91
         int $seconds = null
92 92
     ) : EloquentBuilder {
93
-        if (! $seconds) {
93
+        if (!$seconds) {
94 94
             $seconds = $this->cacheCooldownSeconds;
95 95
         }
96 96
 
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:seconds";
100 100
 
101 101
         $this->cache()
102
-            ->rememberForever($cacheKey, function () use ($seconds) {
102
+            ->rememberForever($cacheKey, function() use ($seconds) {
103 103
                 return $seconds;
104 104
             });
105 105
 
106 106
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:invalidated-at";
107 107
         $this->cache()
108
-            ->rememberForever($cacheKey, function () {
108
+            ->rememberForever($cacheKey, function() {
109 109
                 return (new Carbon)->now();
110 110
             });
111 111
 
Please login to merge, or discard this patch.
src/CacheKey.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -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
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 
75 75
     protected function getOffsetClause() : string
76 76
     {
77
-        if (! $this->query->offset) {
77
+        if (!$this->query->offset) {
78 78
             return "";
79 79
         }
80 80
 
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
         $orders = collect($this->query->orders);
87 87
 
88 88
         return $orders
89
-            ->reduce(function ($carry, $order) {
89
+            ->reduce(function($carry, $order) {
90 90
                 if (($order["type"] ?? "") === "Raw") {
91
-                    return $carry . "_orderByRaw_" . (new Str)->slug($order["sql"]);
91
+                    return $carry."_orderByRaw_".(new Str)->slug($order["sql"]);
92 92
                 }
93 93
 
94
-                return $carry . "_orderBy_" . $order["column"] . "_" . $order["direction"];
94
+                return $carry."_orderBy_".$order["column"]."_".$order["direction"];
95 95
             })
96 96
             ?: "";
97 97
     }
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
     {
101 101
         if (($columns === ["*"]
102 102
                 || $columns === [])
103
-            && ! $this->query->columns
103
+            && !$this->query->columns
104 104
         ) {
105 105
             return "";
106 106
         }
107 107
 
108 108
         if ($this->query->columns) {
109
-            return "_" . implode("_", $this->query->columns);
109
+            return "_".implode("_", $this->query->columns);
110 110
         }
111 111
 
112
-        return "_" . implode("_", $columns);
112
+        return "_".implode("_", $columns);
113 113
     }
114 114
 
115 115
     protected function getTypeClause($where) : string
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
     protected function getValuesClause(array $where = []) : string
125 125
     {
126
-        if (! $where
126
+        if (!$where
127 127
             || in_array($where["type"], ["NotNull", "Null"])
128 128
         ) {
129 129
             return "";
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         $values = $this->getValuesFromWhere($where);
133 133
         $values = $this->getValuesFromBindings($where, $values);
134 134
 
135
-        return "_" . $values;
135
+        return "_".$values;
136 136
     }
137 137
 
138 138
     protected function getValuesFromWhere(array $where) : string
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             $subKey = str_replace($prefix, "", $subKey);
145 145
             $subKey = str_replace($this->getModelSlug(), "", $subKey);
146 146
             $classParts = explode("\\", get_class($this->model));
147
-            $subKey = strtolower(array_pop($classParts)) . $subKey;
147
+            $subKey = strtolower(array_pop($classParts)).$subKey;
148 148
 
149 149
             return $subKey;
150 150
         }
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
             $this->currentBinding++;
164 164
 
165 165
             if ($where["type"] === "between") {
166
-                $values .= "_" . $this->query->bindings["where"][$this->currentBinding];
166
+                $values .= "_".$this->query->bindings["where"][$this->currentBinding];
167 167
                 $this->currentBinding++;
168 168
             }
169 169
         }
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 
174 174
     protected function getWhereClauses(array $wheres = []) : string
175 175
     {
176
-        return "" . $this->getWheres($wheres)
177
-            ->reduce(function ($carry, $where) {
176
+        return "".$this->getWheres($wheres)
177
+            ->reduce(function($carry, $where) {
178 178
                 $value = $carry;
179 179
                 $value .= $this->getNestedClauses($where);
180 180
                 $value .= $this->getColumnClauses($where);
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
 
189 189
     protected function getNestedClauses(array $where) : string
190 190
     {
191
-        if (! in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
191
+        if (!in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
192 192
             return "";
193 193
         }
194 194
 
195
-        return "-" . strtolower($where["type"]) . $this->getWhereClauses($where["query"]->wheres);
195
+        return "-".strtolower($where["type"]).$this->getWhereClauses($where["query"]->wheres);
196 196
     }
197 197
 
198 198
     protected function getColumnClauses(array $where) : string
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
     protected function getInClauses(array $where) : string
208 208
     {
209
-        if (! in_array($where["type"], ["In"])) {
209
+        if (!in_array($where["type"], ["In"])) {
210 210
             return "";
211 211
         }
212 212
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 
219 219
     protected function getInAndNotInClauses(array $where) : string
220 220
     {
221
-        if (! in_array($where["type"], ["In", "NotIn"])) {
221
+        if (!in_array($where["type"], ["In", "NotIn"])) {
222 222
             return "";
223 223
         }
224 224
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
                 continue;
257 257
             }
258 258
 
259
-            $result .= $glue . $value;
259
+            $result .= $glue.$value;
260 260
         }
261 261
 
262 262
         return $result;
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         $clause = "_{$where["boolean"]}";
273 273
 
274 274
         while (count($queryParts) > 1) {
275
-            $clause .= "_" . array_shift($queryParts);
275
+            $clause .= "_".array_shift($queryParts);
276 276
             $clause .= $this->query->bindings["where"][$this->currentBinding];
277 277
             $this->currentBinding++;
278 278
         }
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
         $lastPart = array_shift($queryParts);
281 281
 
282 282
         if ($lastPart) {
283
-            $clause .= "_" . $lastPart;
283
+            $clause .= "_".$lastPart;
284 284
         }
285 285
 
286
-        return "-" . str_replace(" ", "_", $clause);
286
+        return "-".str_replace(" ", "_", $clause);
287 287
     }
288 288
 
289 289
     protected function getOtherClauses(array $where) : string
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
             return "";
318 318
         }
319 319
 
320
-        return $eagerLoads->keys()->reduce(function ($carry, $related) {
321
-            if (! method_exists($this->model, $related)) {
320
+        return $eagerLoads->keys()->reduce(function($carry, $related) {
321
+            if (!method_exists($this->model, $related)) {
322 322
                 return "{$carry}-{$related}";
323 323
             }
324 324
 
Please login to merge, or discard this patch.
src/CachedBuilder.php 1 patch
Spacing   +17 added lines, -17 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
 
@@ -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
 
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 
73 73
     public function first($columns = ["*"])
74 74
     {
75
-        if (! $this->isCachable()) {
75
+        if (!$this->isCachable()) {
76 76
             return parent::first($columns);
77 77
         }
78 78
 
79
-        if (! is_array($columns)) {
79
+        if (!is_array($columns)) {
80 80
             $columns = [$columns];
81 81
         }
82 82
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
     public function get($columns = ["*"])
97 97
     {
98
-        if (! $this->isCachable()) {
98
+        if (!$this->isCachable()) {
99 99
             return parent::get($columns);
100 100
         }
101 101
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 
129 129
     public function max($column)
130 130
     {
131
-        if (! $this->isCachable()) {
131
+        if (!$this->isCachable()) {
132 132
             return parent::max($column);
133 133
         }
134 134
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
     public function min($column)
141 141
     {
142
-        if (! $this->isCachable()) {
142
+        if (!$this->isCachable()) {
143 143
             return parent::min($column);
144 144
         }
145 145
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         $pageName = "page",
155 155
         $page = null
156 156
     ) {
157
-        if (! $this->isCachable()) {
157
+        if (!$this->isCachable()) {
158 158
             return parent::paginate($perPage, $columns, $pageName, $page);
159 159
         }
160 160
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
     {
175 175
         $relation = parent::getRelation($name);
176 176
 
177
-        if (! $this->isCachable()
177
+        if (!$this->isCachable()
178 178
             && is_a($relation->getQuery(), self::class)
179 179
         ) {
180 180
             $relation->getQuery()->disableModelCaching();
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
 
190 190
         foreach ($items as $key => $value) {
191 191
             if (is_array($value)) {
192
-                $result .= $key . $glue . $this->recursiveImplodeWithKey($value, $glue);
192
+                $result .= $key.$glue.$this->recursiveImplodeWithKey($value, $glue);
193 193
 
194 194
                 continue;
195 195
             }
196 196
 
197
-            $result .= $glue . $key . $glue . $value;
197
+            $result .= $glue.$key.$glue.$value;
198 198
         }
199 199
 
200 200
         return $result;
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
 
203 203
     public function pluck($column, $key = null)
204 204
     {
205
-        if (! $this->isCachable()) {
205
+        if (!$this->isCachable()) {
206 206
             return parent::pluck($column, $key);
207 207
         }
208 208
 
209
-        $keyDifferentiator = "-pluck_{$column}" . ($key ? "_{$key}" : "");
209
+        $keyDifferentiator = "-pluck_{$column}".($key ? "_{$key}" : "");
210 210
         $cacheKey = $this->makeCacheKey([$column], null, $keyDifferentiator);
211 211
 
212 212
         return $this->cachedValue(func_get_args(), $cacheKey);
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 
215 215
     public function sum($column)
216 216
     {
217
-        if (! $this->isCachable()) {
217
+        if (!$this->isCachable()) {
218 218
             return parent::sum($column);
219 219
         }
220 220
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 
233 233
     public function value($column)
234 234
     {
235
-        if (! $this->isCachable()) {
235
+        if (!$this->isCachable()) {
236 236
             return parent::value($column);
237 237
         }
238 238
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         return $this->cache($cacheTags)
302 302
             ->rememberForever(
303 303
                 $hashedCacheKey,
304
-                function () use ($arguments, $cacheKey, $method) {
304
+                function() use ($arguments, $cacheKey, $method) {
305 305
                     return [
306 306
                         "key" => $cacheKey,
307 307
                         "value" => parent::{$method}(...$arguments),
Please login to merge, or discard this patch.