Passed
Push — master ( 97df37...bd1e6e )
by Mike
04:07 queued 10s
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/Traits/Buildable.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 {
11 11
     public function avg($column)
12 12
     {
13
-        if (! $this->isCachable()) {
13
+        if (!$this->isCachable()) {
14 14
             return parent::avg($column);
15 15
         }
16 16
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
     public function count($columns = "*")
23 23
     {
24
-        if (! $this->isCachable()) {
24
+        if (!$this->isCachable()) {
25 25
             return parent::count($columns);
26 26
         }
27 27
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function find($id, $columns = ["*"])
53 53
     {
54
-        if (! $this->isCachable()) {
54
+        if (!$this->isCachable()) {
55 55
             return parent::find($id, $columns);
56 56
         }
57 57
 
@@ -67,11 +67,11 @@  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
 
74
-        if (! is_array($columns)) {
74
+        if (!is_array($columns)) {
75 75
             $columns = [$columns];
76 76
         }
77 77
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
     public function get($columns = ["*"])
92 92
     {
93
-        if (! $this->isCachable()) {
93
+        if (!$this->isCachable()) {
94 94
             return parent::get($columns);
95 95
         }
96 96
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
     public function max($column)
125 125
     {
126
-        if (! $this->isCachable()) {
126
+        if (!$this->isCachable()) {
127 127
             return parent::max($column);
128 128
         }
129 129
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
     public function min($column)
136 136
     {
137
-        if (! $this->isCachable()) {
137
+        if (!$this->isCachable()) {
138 138
             return parent::min($column);
139 139
         }
140 140
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         $pageName = "page",
150 150
         $page = null
151 151
     ) {
152
-        if (! $this->isCachable()) {
152
+        if (!$this->isCachable()) {
153 153
             return parent::paginate($perPage, $columns, $pageName, $page);
154 154
         }
155 155
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
     {
170 170
         $relation = parent::getRelation($name);
171 171
 
172
-        if (! $this->isCachable()
172
+        if (!$this->isCachable()
173 173
             && is_a($relation->getQuery(), self::class)
174 174
         ) {
175 175
             $relation->getQuery()->disableModelCaching();
@@ -184,12 +184,12 @@  discard block
 block discarded – undo
184 184
 
185 185
         foreach ($items as $key => $value) {
186 186
             if (is_array($value)) {
187
-                $result .= $key . $glue . $this->recursiveImplodeWithKey($value, $glue);
187
+                $result .= $key.$glue.$this->recursiveImplodeWithKey($value, $glue);
188 188
 
189 189
                 continue;
190 190
             }
191 191
 
192
-            $result .= $glue . $key . $glue . $value;
192
+            $result .= $glue.$key.$glue.$value;
193 193
         }
194 194
 
195 195
         return $result;
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
 
198 198
     public function pluck($column, $key = null)
199 199
     {
200
-        if (! $this->isCachable()) {
200
+        if (!$this->isCachable()) {
201 201
             return parent::pluck($column, $key);
202 202
         }
203 203
 
204
-        $keyDifferentiator = "-pluck_{$column}" . ($key ? "_{$key}" : "");
204
+        $keyDifferentiator = "-pluck_{$column}".($key ? "_{$key}" : "");
205 205
         $cacheKey = $this->makeCacheKey([$column], null, $keyDifferentiator);
206 206
 
207 207
         return $this->cachedValue(func_get_args(), $cacheKey);
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 
210 210
     public function sum($column)
211 211
     {
212
-        if (! $this->isCachable()) {
212
+        if (!$this->isCachable()) {
213 213
             return parent::sum($column);
214 214
         }
215 215
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
     public function value($column)
229 229
     {
230
-        if (! $this->isCachable()) {
230
+        if (!$this->isCachable()) {
231 231
             return parent::value($column);
232 232
         }
233 233
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
         return $this->cache($cacheTags)
307 307
             ->rememberForever(
308 308
                 $hashedCacheKey,
309
-                function () use ($arguments, $cacheKey, $method) {
309
+                function() use ($arguments, $cacheKey, $method) {
310 310
                     return [
311 311
                         "key" => $cacheKey,
312 312
                         "value" => parent::{$method}(...$arguments),
Please login to merge, or discard this patch.
src/CacheKey.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 
55 55
     protected function getLimitClause() : string
56 56
     {
57
-        if (! property_exists($this->query, "limit")
58
-            || ! $this->query->limit
57
+        if (!property_exists($this->query, "limit")
58
+            || !$this->query->limit
59 59
         ) {
60 60
             return "";
61 61
         }
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 
77 77
     protected function getOffsetClause() : string
78 78
     {
79
-        if (! property_exists($this->query, "offset")
80
-            || ! $this->query->offset
79
+        if (!property_exists($this->query, "offset")
80
+            || !$this->query->offset
81 81
         ) {
82 82
             return "";
83 83
         }
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 
88 88
     protected function getOrderByClauses() : string
89 89
     {
90
-        if (! property_exists($this->query, "orders")
91
-            || ! $this->query->orders
90
+        if (!property_exists($this->query, "orders")
91
+            || !$this->query->orders
92 92
         ) {
93 93
             return "";
94 94
         }
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
         $orders = collect($this->query->orders);
97 97
 
98 98
         return $orders
99
-            ->reduce(function ($carry, $order) {
99
+            ->reduce(function($carry, $order) {
100 100
                 if (($order["type"] ?? "") === "Raw") {
101
-                    return $carry . "_orderByRaw_" . (new Str)->slug($order["sql"]);
101
+                    return $carry."_orderByRaw_".(new Str)->slug($order["sql"]);
102 102
                 }
103 103
 
104
-                return $carry . "_orderBy_" . $order["column"] . "_" . $order["direction"];
104
+                return $carry."_orderBy_".$order["column"]."_".$order["direction"];
105 105
             })
106 106
             ?: "";
107 107
     }
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
     {
111 111
         if (($columns === ["*"]
112 112
                 || $columns === [])
113
-            && (! property_exists($this->query, "columns")
114
-                || ! $this->query->columns)
113
+            && (!property_exists($this->query, "columns")
114
+                || !$this->query->columns)
115 115
         ) {
116 116
             return "";
117 117
         }
@@ -119,10 +119,10 @@  discard block
 block discarded – undo
119 119
         if (property_exists($this->query, "columns")
120 120
             && $this->query->columns
121 121
         ) {
122
-            return "_" . implode("_", $this->query->columns);
122
+            return "_".implode("_", $this->query->columns);
123 123
         }
124 124
 
125
-        return "_" . implode("_", $columns);
125
+        return "_".implode("_", $columns);
126 126
     }
127 127
 
128 128
     protected function getTypeClause($where) : string
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
     protected function getValuesClause(array $where = []) : string
138 138
     {
139
-        if (! $where
139
+        if (!$where
140 140
             || in_array($where["type"], ["NotNull", "Null"])
141 141
         ) {
142 142
             return "";
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         $values = $this->getValuesFromWhere($where);
146 146
         $values = $this->getValuesFromBindings($where, $values);
147 147
 
148
-        return "_" . $values;
148
+        return "_".$values;
149 149
     }
150 150
 
151 151
     protected function getValuesFromWhere(array $where) : string
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
             $subKey = str_replace($prefix, "", $subKey);
158 158
             $subKey = str_replace($this->getModelSlug(), "", $subKey);
159 159
             $classParts = explode("\\", get_class($this->model));
160
-            $subKey = strtolower(array_pop($classParts)) . $subKey;
160
+            $subKey = strtolower(array_pop($classParts)).$subKey;
161 161
 
162 162
             return $subKey;
163 163
         }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
             $this->currentBinding++;
177 177
 
178 178
             if ($where["type"] === "between") {
179
-                $values .= "_" . $this->query->bindings["where"][$this->currentBinding];
179
+                $values .= "_".$this->query->bindings["where"][$this->currentBinding];
180 180
                 $this->currentBinding++;
181 181
             }
182 182
         }
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 
187 187
     protected function getWhereClauses(array $wheres = []) : string
188 188
     {
189
-        return "" . $this->getWheres($wheres)
190
-            ->reduce(function ($carry, $where) {
189
+        return "".$this->getWheres($wheres)
190
+            ->reduce(function($carry, $where) {
191 191
                 $value = $carry;
192 192
                 $value .= $this->getNestedClauses($where);
193 193
                 $value .= $this->getColumnClauses($where);
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 
202 202
     protected function getNestedClauses(array $where) : string
203 203
     {
204
-        if (! in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
204
+        if (!in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
205 205
             return "";
206 206
         }
207 207
 
208
-        return "-" . strtolower($where["type"]) . $this->getWhereClauses($where["query"]->wheres);
208
+        return "-".strtolower($where["type"]).$this->getWhereClauses($where["query"]->wheres);
209 209
     }
210 210
 
211 211
     protected function getColumnClauses(array $where) : string
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
     protected function getInClauses(array $where) : string
221 221
     {
222
-        if (! in_array($where["type"], ["In"])) {
222
+        if (!in_array($where["type"], ["In"])) {
223 223
             return "";
224 224
         }
225 225
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
     protected function getInAndNotInClauses(array $where) : string
233 233
     {
234
-        if (! in_array($where["type"], ["In", "NotIn", "InRaw"])) {
234
+        if (!in_array($where["type"], ["In", "NotIn", "InRaw"])) {
235 235
             return "";
236 236
         }
237 237
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
                 continue;
270 270
             }
271 271
 
272
-            $result .= $glue . $value;
272
+            $result .= $glue.$value;
273 273
         }
274 274
 
275 275
         return $result;
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 
278 278
     protected function getRawClauses(array $where) : string
279 279
     {
280
-        if (! in_array($where["type"], ["raw"])) {
280
+        if (!in_array($where["type"], ["raw"])) {
281 281
             return "";
282 282
         }
283 283
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
         $clause = "_{$where["boolean"]}";
286 286
 
287 287
         while (count($queryParts) > 1) {
288
-            $clause .= "_" . array_shift($queryParts);
288
+            $clause .= "_".array_shift($queryParts);
289 289
             $clause .= $this->query->bindings["where"][$this->currentBinding];
290 290
             $this->currentBinding++;
291 291
         }
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
         $lastPart = array_shift($queryParts);
294 294
 
295 295
         if ($lastPart) {
296
-            $clause .= "_" . $lastPart;
296
+            $clause .= "_".$lastPart;
297 297
         }
298 298
 
299
-        return "-" . str_replace(" ", "_", $clause);
299
+        return "-".str_replace(" ", "_", $clause);
300 300
     }
301 301
 
302 302
     protected function getOtherClauses(array $where) : string
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
             return "";
333 333
         }
334 334
 
335
-        return $eagerLoads->keys()->reduce(function ($carry, $related) {
336
-            if (! method_exists($this->model, $related)) {
335
+        return $eagerLoads->keys()->reduce(function($carry, $related) {
336
+            if (!method_exists($this->model, $related)) {
337 337
                 return "{$carry}-{$related}";
338 338
             }
339 339
 
Please login to merge, or discard this patch.