Completed
Pull Request — master (#3)
by Mike
07:27
created
src/CachedModel.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,19 +23,19 @@  discard block
 block discarded – undo
23 23
         $class = get_called_class();
24 24
         $instance = new $class;
25 25
 
26
-        static::created(function () use ($instance) {
26
+        static::created(function() use ($instance) {
27 27
             $instance->flushCache();
28 28
         });
29 29
 
30
-        static::deleted(function () use ($instance) {
30
+        static::deleted(function() use ($instance) {
31 31
             $instance->flushCache();
32 32
         });
33 33
 
34
-        static::saved(function () use ($instance) {
34
+        static::saved(function() use ($instance) {
35 35
             $instance->flushCache();
36 36
         });
37 37
 
38
-        static::updated(function () use ($instance) {
38
+        static::updated(function() use ($instance) {
39 39
             $instance->flushCache();
40 40
         });
41 41
     }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         $key = 'genealabslaravelmodelcachingtestsfixturesauthor';
66 66
 
67 67
         return $instance->cache($tags)
68
-            ->rememberForever($key, function () use ($columns) {
68
+            ->rememberForever($key, function() use ($columns) {
69 69
                 return parent::all($columns);
70 70
             });
71 71
     }
Please login to merge, or discard this patch.
src/CachedBuilder.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
     protected function getLimitClause() : string
42 42
     {
43
-        if (! $this->query->limit) {
43
+        if (!$this->query->limit) {
44 44
             return '';
45 45
         }
46 46
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
     protected function getOffsetClause() : string
56 56
     {
57
-        if (! $this->query->offset) {
57
+        if (!$this->query->offset) {
58 58
             return '';
59 59
         }
60 60
 
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
             return '';
68 68
         }
69 69
 
70
-        return '_' . implode('_', $columns);
70
+        return '_'.implode('_', $columns);
71 71
     }
72 72
 
73 73
     protected function getWhereClauses() : string
74 74
     {
75
-        return collect($this->query->wheres)->reduce(function ($carry, $where) {
75
+        return collect($this->query->wheres)->reduce(function($carry, $where) {
76 76
             $value = $where['value'] ?? implode('_', ($where['values'] ?? []));
77 77
 
78
-            if (! $value) {
79
-                return $carry . '';
78
+            if (!$value) {
79
+                return $carry.'';
80 80
             }
81 81
 
82 82
             return "{$carry}-{$where['column']}_{$value}";
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
             return '';
92 92
         }
93 93
 
94
-        return '-' . implode('-', $eagerLoads->keys()->toArray());
94
+        return '-'.implode('-', $eagerLoads->keys()->toArray());
95 95
     }
96 96
 
97 97
     protected function getCacheTags() : array
98 98
     {
99 99
         return collect($this->eagerLoad)->keys()
100
-            ->map(function ($relationName) {
100
+            ->map(function($relationName) {
101 101
                 $relation = collect(explode('.', $relationName))
102
-                    ->reduce(function ($carry, $name) {
103
-                        if (! $carry) {
102
+                    ->reduce(function($carry, $name) {
103
+                        if (!$carry) {
104 104
                             $carry = $this->model;
105 105
                         }
106 106
 
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
     public function avg($column)
122 122
     {
123 123
         $tags = [str_slug(get_class($this->model))];
124
-        $key = str_slug(get_class($this->model)) ."-avg_{$column}";
124
+        $key = str_slug(get_class($this->model))."-avg_{$column}";
125 125
 
126 126
         return $this->cache($tags)
127
-            ->rememberForever($key, function () use ($column) {
127
+            ->rememberForever($key, function() use ($column) {
128 128
                 return parent::avg($column);
129 129
             });
130 130
     }
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
     public function count($columns = ['*'])
133 133
     {
134 134
         $tags = [str_slug(get_class($this->model))];
135
-        $key = str_slug(get_class($this->model)) ."-count";
135
+        $key = str_slug(get_class($this->model))."-count";
136 136
 
137 137
         return $this->cache($tags)
138
-            ->rememberForever($key, function () use ($columns) {
138
+            ->rememberForever($key, function() use ($columns) {
139 139
                 return parent::count($columns);
140 140
             });
141 141
     }
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
     public function cursor()
144 144
     {
145 145
         $tags = [str_slug(get_class($this->model))];
146
-        $key = str_slug(get_class($this->model)) ."-cursor";
146
+        $key = str_slug(get_class($this->model))."-cursor";
147 147
 
148 148
         return $this->cache($tags)
149
-            ->rememberForever($key, function () {
149
+            ->rememberForever($key, function() {
150 150
                 return collect(parent::cursor());
151 151
             });
152 152
     }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         $key = $this->getCacheKey($columns, $id);
161 161
 
162 162
         return $this->cache($tags)
163
-            ->rememberForever($key, function () use ($id, $columns) {
163
+            ->rememberForever($key, function() use ($id, $columns) {
164 164
                 return parent::find($id, $columns);
165 165
             });
166 166
     }
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
     public function first($columns = ['*'])
169 169
     {
170 170
         $tags = $this->getCacheTags();
171
-        $key = $this->getCacheKey($columns) . '-first';
171
+        $key = $this->getCacheKey($columns).'-first';
172 172
 
173 173
         return $this->cache($tags)
174
-            ->rememberForever($key, function () use ($columns) {
174
+            ->rememberForever($key, function() use ($columns) {
175 175
                 return parent::first($columns);
176 176
             });
177 177
     }
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         $key = $this->getCacheKey($columns);
183 183
 
184 184
         return $this->cache($tags)
185
-            ->rememberForever($key, function () use ($columns) {
185
+            ->rememberForever($key, function() use ($columns) {
186 186
                 return parent::get($columns);
187 187
             });
188 188
     }
@@ -190,10 +190,10 @@  discard block
 block discarded – undo
190 190
     public function max($column)
191 191
     {
192 192
         $tags = [str_slug(get_class($this->model))];
193
-        $key = str_slug(get_class($this->model)) ."-max_{$column}";
193
+        $key = str_slug(get_class($this->model))."-max_{$column}";
194 194
 
195 195
         return $this->cache($tags)
196
-            ->rememberForever($key, function () use ($column) {
196
+            ->rememberForever($key, function() use ($column) {
197 197
                 return parent::max($column);
198 198
             });
199 199
     }
@@ -201,10 +201,10 @@  discard block
 block discarded – undo
201 201
     public function min($column)
202 202
     {
203 203
         $tags = [str_slug(get_class($this->model))];
204
-        $key = str_slug(get_class($this->model)) ."-min_{$column}";
204
+        $key = str_slug(get_class($this->model))."-min_{$column}";
205 205
 
206 206
         return $this->cache($tags)
207
-            ->rememberForever($key, function () use ($column) {
207
+            ->rememberForever($key, function() use ($column) {
208 208
                 return parent::min($column);
209 209
             });
210 210
     }
@@ -212,14 +212,14 @@  discard block
 block discarded – undo
212 212
     public function pluck($column, $key = null)
213 213
     {
214 214
         $tags = $this->getCacheTags();
215
-        $cacheKey = $this->getCacheKey([$column]) . "-pluck_{$column}";
215
+        $cacheKey = $this->getCacheKey([$column])."-pluck_{$column}";
216 216
 
217 217
         if ($key) {
218 218
             $cacheKey .= "_{$key}";
219 219
         }
220 220
 
221 221
         return $this->cache($tags)
222
-            ->rememberForever($cacheKey, function () use ($column, $key) {
222
+            ->rememberForever($cacheKey, function() use ($column, $key) {
223 223
                 return parent::pluck($column, $key);
224 224
             });
225 225
     }
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
     public function sum($column)
228 228
     {
229 229
         $tags = [str_slug(get_class($this->model))];
230
-        $key = str_slug(get_class($this->model)) ."-sum_{$column}";
230
+        $key = str_slug(get_class($this->model))."-sum_{$column}";
231 231
 
232 232
         return $this->cache($tags)
233
-            ->rememberForever($key, function () use ($column) {
233
+            ->rememberForever($key, function() use ($column) {
234 234
                 return parent::sum($column);
235 235
             });
236 236
     }
Please login to merge, or discard this patch.