Completed
Pull Request — master (#409)
by Mike
29s
created
src/Traits/Buildable.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 {
10 10
     public function avg($column)
11 11
     {
12
-        if (! $this->isCachable()) {
12
+        if (!$this->isCachable()) {
13 13
             return parent::avg($column);
14 14
         }
15 15
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
     public function count($columns = "*")
22 22
     {
23
-        if (! $this->isCachable()) {
23
+        if (!$this->isCachable()) {
24 24
             return parent::count($columns);
25 25
         }
26 26
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
     public function exists()
33 33
     {
34
-        if (! $this->isCachable()) {
34
+        if (!$this->isCachable()) {
35 35
             return parent::exists();
36 36
         }
37 37
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function find($id, $columns = ["*"])
63 63
     {
64
-        if (! $this->isCachable()) {
64
+        if (!$this->isCachable()) {
65 65
             return parent::find($id, $columns);
66 66
         }
67 67
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
     public function first($columns = ["*"])
80 80
     {
81
-        if (! $this->isCachable()) {
81
+        if (!$this->isCachable()) {
82 82
             return parent::first($columns);
83 83
         }
84 84
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
     public function get($columns = ["*"])
100 100
     {
101
-        if (! $this->isCachable()) {
101
+        if (!$this->isCachable()) {
102 102
             return parent::get($columns);
103 103
         }
104 104
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
     public function max($column)
136 136
     {
137
-        if (! $this->isCachable()) {
137
+        if (!$this->isCachable()) {
138 138
             return parent::max($column);
139 139
         }
140 140
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
     public function min($column)
147 147
     {
148
-        if (! $this->isCachable()) {
148
+        if (!$this->isCachable()) {
149 149
             return parent::min($column);
150 150
         }
151 151
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         $pageName = "page",
161 161
         $page = null
162 162
     ) {
163
-        if (! $this->isCachable()) {
163
+        if (!$this->isCachable()) {
164 164
             return parent::paginate($perPage, $columns, $pageName, $page);
165 165
         }
166 166
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         $result = "";
185 185
 
186 186
         foreach ($items as $key => $value) {
187
-            $result .= $glue . $key . $glue . $value;
187
+            $result .= $glue.$key.$glue.$value;
188 188
         }
189 189
 
190 190
         return $result;
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 
193 193
     public function pluck($column, $key = null)
194 194
     {
195
-        if (! $this->isCachable()) {
195
+        if (!$this->isCachable()) {
196 196
             return parent::pluck($column, $key);
197 197
         }
198 198
 
199
-        $keyDifferentiator = "-pluck_{$column}" . ($key ? "_{$key}" : "");
199
+        $keyDifferentiator = "-pluck_{$column}".($key ? "_{$key}" : "");
200 200
         $cacheKey = $this->makeCacheKey([$column], null, $keyDifferentiator);
201 201
 
202 202
         return $this->cachedValue(func_get_args(), $cacheKey);
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
     public function sum($column)
206 206
     {
207
-        if (! $this->isCachable()) {
207
+        if (!$this->isCachable()) {
208 208
             return parent::sum($column);
209 209
         }
210 210
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
     public function value($column)
226 226
     {
227
-        if (! $this->isCachable()) {
227
+        if (!$this->isCachable()) {
228 228
             return parent::value($column);
229 229
         }
230 230
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
         return $this->cache($cacheTags)
300 300
             ->rememberForever(
301 301
                 $hashedCacheKey,
302
-                function () use ($arguments, $cacheKey, $method) {
302
+                function() use ($arguments, $cacheKey, $method) {
303 303
                     return [
304 304
                         "key" => $cacheKey,
305 305
                         "value" => parent::{$method}(...$arguments),
Please login to merge, or discard this patch.
tests/Integration/CachedBuilder/BooleanTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         factory(Book::class)->create(['author_id' => $expectedAuthor->getKey(), 'title' => 'Mixed Clause']);
68 68
 
69 69
         $books = (new Book)
70
-            ->whereHas('author', function ($query) {
70
+            ->whereHas('author', function($query) {
71 71
                 return $query->where('is_famous', false);
72 72
             })
73 73
             ->whereRaw("title = ?", ['Mixed Clause']) // Test ensures this binding is included in the key
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             ->tags($tags)
77 77
             ->get($key)['value'];
78 78
         $liveResults = (new UncachedBook)
79
-            ->whereHas('author', function ($query) {
79
+            ->whereHas('author', function($query) {
80 80
                 return $query->where('is_famous', false);
81 81
             })
82 82
             ->whereRaw("title = ?", ['Mixed Clause'])
Please login to merge, or discard this patch.
src/CacheKey.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
     protected function getBindingsSlug() : string
55 55
     {
56
-        if (! method_exists($this->model, 'query')) {
56
+        if (!method_exists($this->model, 'query')) {
57 57
             return '';
58 58
         }
59 59
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
     protected function getInAndNotInClauses(array $where) : string
83 83
     {
84
-        if (! in_array($where["type"], ["In", "NotIn", "InRaw"])) {
84
+        if (!in_array($where["type"], ["In", "NotIn", "InRaw"])) {
85 85
             return "";
86 86
         }
87 87
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             $this->currentBinding += count($where["values"]);
94 94
         }
95 95
 
96
-        if (! is_numeric($subquery) && ! is_numeric(str_replace("_", "", $subquery))) {
96
+        if (!is_numeric($subquery) && !is_numeric(str_replace("_", "", $subquery))) {
97 97
             try {
98 98
                 $subquery = Uuid::fromBytes($subquery);
99 99
                 $values = $this->recursiveImplode([$subquery], "_");
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
 
114 114
     protected function getLimitClause() : string
115 115
     {
116
-        if (! property_exists($this->query, "limit")
117
-            || ! $this->query->limit
116
+        if (!property_exists($this->query, "limit")
117
+            || !$this->query->limit
118 118
         ) {
119 119
             return "";
120 120
         }
@@ -129,17 +129,17 @@  discard block
 block discarded – undo
129 129
 
130 130
     protected function getNestedClauses(array $where) : string
131 131
     {
132
-        if (! in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
132
+        if (!in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
133 133
             return "";
134 134
         }
135 135
 
136
-        return "-" . strtolower($where["type"]) . $this->getWhereClauses($where["query"]->wheres);
136
+        return "-".strtolower($where["type"]).$this->getWhereClauses($where["query"]->wheres);
137 137
     }
138 138
 
139 139
     protected function getOffsetClause() : string
140 140
     {
141
-        if (! property_exists($this->query, "offset")
142
-            || ! $this->query->offset
141
+        if (!property_exists($this->query, "offset")
142
+            || !$this->query->offset
143 143
         ) {
144 144
             return "";
145 145
         }
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 
150 150
     protected function getOrderByClauses() : string
151 151
     {
152
-        if (! property_exists($this->query, "orders")
153
-            || ! $this->query->orders
152
+        if (!property_exists($this->query, "orders")
153
+            || !$this->query->orders
154 154
         ) {
155 155
             return "";
156 156
         }
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
         $orders = collect($this->query->orders);
159 159
 
160 160
         return $orders
161
-            ->reduce(function ($carry, $order) {
161
+            ->reduce(function($carry, $order) {
162 162
                 if (($order["type"] ?? "") === "Raw") {
163
-                    return $carry . "_orderByRaw_" . (new Str)->slug($order["sql"]);
163
+                    return $carry."_orderByRaw_".(new Str)->slug($order["sql"]);
164 164
                 }
165 165
 
166
-                return $carry . "_orderBy_" . $order["column"] . "_" . $order["direction"];
166
+                return $carry."_orderBy_".$order["column"]."_".$order["direction"];
167 167
             })
168 168
             ?: "";
169 169
     }
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
     {
185 185
         if (($columns === ["*"]
186 186
                 || $columns === [])
187
-            && (! property_exists($this->query, "columns")
188
-                || ! $this->query->columns)
187
+            && (!property_exists($this->query, "columns")
188
+                || !$this->query->columns)
189 189
         ) {
190 190
             return "";
191 191
         }
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
         if (property_exists($this->query, "columns")
194 194
             && $this->query->columns
195 195
         ) {
196
-            return "_" . implode("_", $this->query->columns);
196
+            return "_".implode("_", $this->query->columns);
197 197
         }
198 198
 
199
-        return "_" . implode("_", $columns);
199
+        return "_".implode("_", $columns);
200 200
     }
201 201
 
202 202
     protected function getRawClauses(array $where) : string
203 203
     {
204
-        if (! in_array($where["type"], ["raw"])) {
204
+        if (!in_array($where["type"], ["raw"])) {
205 205
             return "";
206 206
         }
207 207
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         $clause = "_{$where["boolean"]}";
210 210
 
211 211
         while (count($queryParts) > 1) {
212
-            $clause .= "_" . array_shift($queryParts);
212
+            $clause .= "_".array_shift($queryParts);
213 213
             $clause .= $this->getCurrentBinding('where');
214 214
             $this->currentBinding++;
215 215
         }
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
         $lastPart = array_shift($queryParts);
218 218
 
219 219
         if ($lastPart) {
220
-            $clause .= "_" . $lastPart;
220
+            $clause .= "_".$lastPart;
221 221
         }
222 222
 
223
-        return "-" . str_replace(" ", "_", $clause);
223
+        return "-".str_replace(" ", "_", $clause);
224 224
     }
225 225
 
226 226
     protected function getTableSlug() : string
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 
241 241
     protected function getValuesClause(array $where = []) : string
242 242
     {
243
-        if (! $where
243
+        if (!$where
244 244
             || in_array($where["type"], ["NotNull", "Null"])
245 245
         ) {
246 246
             return "";
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
         $values = $this->getValuesFromWhere($where);
250 250
         $values = $this->getValuesFromBindings($where, $values);
251 251
 
252
-        return "_" . $values;
252
+        return "_".$values;
253 253
     }
254 254
 
255 255
     protected function getValuesFromWhere(array $where) : string
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 
275 275
     protected function getValuesFromBindings(array $where, string $values) : string
276 276
     {
277
-        $bindingFallback = __CLASS__ . ':UNKNOWN_BINDING';
277
+        $bindingFallback = __CLASS__.':UNKNOWN_BINDING';
278 278
         $currentBinding = $this->getCurrentBinding('where', $bindingFallback);
279 279
 
280 280
         if ($currentBinding !== $bindingFallback) {
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
             $this->currentBinding++;
283 283
 
284 284
             if ($where["type"] === "between") {
285
-                $values .= "_" . $this->getCurrentBinding('where');
285
+                $values .= "_".$this->getCurrentBinding('where');
286 286
                 $this->currentBinding++;
287 287
             }
288 288
         }
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
 
299 299
     protected function getWhereClauses(array $wheres = []) : string
300 300
     {
301
-        return "" . $this->getWheres($wheres)
302
-            ->reduce(function ($carry, $where) {
301
+        return "".$this->getWheres($wheres)
302
+            ->reduce(function($carry, $where) {
303 303
                 $value = $carry;
304 304
                 $value .= $this->getNestedClauses($where);
305 305
                 $value .= $this->getColumnClauses($where);
@@ -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
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
                 continue;
366 366
             }
367 367
 
368
-            $result .= $glue . $value;
368
+            $result .= $glue.$value;
369 369
         }
370 370
 
371 371
         return $result;
Please login to merge, or discard this patch.