Completed
Push — master ( 37cb15...9881f1 )
by Mike
42s queued 11s
created
src/Traits/Caching.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -34,18 +34,18 @@  discard block
 block discarded – undo
34 34
 
35 35
     protected function applyScopesToInstance()
36 36
     {
37
-        if (! property_exists($this, "scopes")
37
+        if (!property_exists($this, "scopes")
38 38
             || $this->scopesAreApplied
39 39
         ) {
40 40
             return;
41 41
         }
42 42
 
43 43
         foreach ($this->scopes as $identifier => $scope) {
44
-            if (! isset($this->scopes[$identifier])) {
44
+            if (!isset($this->scopes[$identifier])) {
45 45
                 continue;
46 46
             }
47 47
 
48
-            $this->callScope(function () use ($scope) {
48
+            $this->callScope(function() use ($scope) {
49 49
                 if ($scope instanceof Closure) {
50 50
                     $scope($this);
51 51
                 }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
             $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
104 104
 
105 105
             $this->cache()
106
-                ->rememberForever($cacheKey, function () {
106
+                ->rememberForever($cacheKey, function() {
107 107
                     return (new Carbon)->now();
108 108
                 });
109 109
         }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
     public function getModelCacheCooldown(Model $instance) : array
182 182
     {
183
-        if (! $instance->cacheCooldownSeconds) {
183
+        if (!$instance->cacheCooldownSeconds) {
184 184
             return [null, null, null];
185 185
         }
186 186
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
         [$cacheCooldown, $invalidatedAt, $savedAt] = $this
190 190
             ->getCacheCooldownDetails($instance, $cachePrefix, $modelClassName);
191 191
 
192
-        if (! $cacheCooldown || $cacheCooldown === 0) {
192
+        if (!$cacheCooldown || $cacheCooldown === 0) {
193 193
             return [null, null, null];
194 194
         }
195 195
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
     {
219 219
         [$cacheCooldown, $invalidatedAt] = $this->getModelCacheCooldown($instance);
220 220
 
221
-        if (! $cacheCooldown
221
+        if (!$cacheCooldown
222 222
             || (new Carbon)->now()->diffInSeconds($invalidatedAt) < $cacheCooldown
223 223
         ) {
224 224
             return;
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     {
244 244
         [$cacheCooldown, $invalidatedAt] = $instance->getModelCacheCooldown($instance);
245 245
 
246
-        if (! $cacheCooldown) {
246
+        if (!$cacheCooldown) {
247 247
             $instance->flushCache();
248 248
 
249 249
             if ($relationship) {
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 
271 271
     public function isCachable() : bool
272 272
     {
273
-        $isCacheDisabled = ! Container::getInstance()
273
+        $isCacheDisabled = !Container::getInstance()
274 274
             ->make("config")
275 275
             ->get("laravel-model-caching.enabled");
276 276
         $allRelationshipsAreCachable = true;
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
             $allRelationshipsAreCachable = collect($this
282 282
                 ->eagerLoad)
283 283
                 ->keys()
284
-                ->reduce(function ($carry, $related) {
285
-                    if (! method_exists($this, $related)
284
+                ->reduce(function($carry, $related) {
285
+                    if (!method_exists($this, $related)
286 286
                         || $carry === false
287 287
                     ) {
288 288
                         return $carry;
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
         
291 291
                     $relatedModel = $this->model->$related()->getRelated();
292 292
 
293
-                    if (! method_exists($relatedModel, "isCachable")
294
-                        || ! $relatedModel->isCachable()
293
+                    if (!method_exists($relatedModel, "isCachable")
294
+                        || !$relatedModel->isCachable()
295 295
                     ) {
296 296
                         return false;
297 297
                     }
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
         }
303 303
 
304 304
         return $this->isCachable
305
-            && ! $isCacheDisabled
305
+            && !$isCacheDisabled
306 306
             && $allRelationshipsAreCachable;
307 307
     }
308 308
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at";
314 314
 
315 315
         $instance->cache()
316
-            ->rememberForever($cacheKey, function () {
316
+            ->rememberForever($cacheKey, function() {
317 317
                 return (new Carbon)->now();
318 318
             });
319 319
     }
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
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 
59 59
     protected function getLimitClause() : string
60 60
     {
61
-        if (! property_exists($this->query, "limit")
62
-            || ! $this->query->limit
61
+        if (!property_exists($this->query, "limit")
62
+            || !$this->query->limit
63 63
         ) {
64 64
             return "";
65 65
         }
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 
81 81
     protected function getOffsetClause() : string
82 82
     {
83
-        if (! property_exists($this->query, "offset")
84
-            || ! $this->query->offset
83
+        if (!property_exists($this->query, "offset")
84
+            || !$this->query->offset
85 85
         ) {
86 86
             return "";
87 87
         }
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 
92 92
     protected function getOrderByClauses() : string
93 93
     {
94
-        if (! property_exists($this->query, "orders")
95
-            || ! $this->query->orders
94
+        if (!property_exists($this->query, "orders")
95
+            || !$this->query->orders
96 96
         ) {
97 97
             return "";
98 98
         }
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
         $orders = collect($this->query->orders);
101 101
 
102 102
         return $orders
103
-            ->reduce(function ($carry, $order) {
103
+            ->reduce(function($carry, $order) {
104 104
                 if (($order["type"] ?? "") === "Raw") {
105
-                    return $carry . "_orderByRaw_" . (new Str)->slug($order["sql"]);
105
+                    return $carry."_orderByRaw_".(new Str)->slug($order["sql"]);
106 106
                 }
107 107
 
108
-                return $carry . "_orderBy_" . $order["column"] . "_" . $order["direction"];
108
+                return $carry."_orderBy_".$order["column"]."_".$order["direction"];
109 109
             })
110 110
             ?: "";
111 111
     }
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
     {
115 115
         if (($columns === ["*"]
116 116
                 || $columns === [])
117
-            && (! property_exists($this->query, "columns")
118
-                || ! $this->query->columns)
117
+            && (!property_exists($this->query, "columns")
118
+                || !$this->query->columns)
119 119
         ) {
120 120
             return "";
121 121
         }
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
         if (property_exists($this->query, "columns")
124 124
             && $this->query->columns
125 125
         ) {
126
-            return "_" . implode("_", $this->query->columns);
126
+            return "_".implode("_", $this->query->columns);
127 127
         }
128 128
 
129
-        return "_" . implode("_", $columns);
129
+        return "_".implode("_", $columns);
130 130
     }
131 131
 
132 132
     protected function getTypeClause($where) : string
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
     protected function getValuesClause(array $where = []) : string
142 142
     {
143
-        if (! $where
143
+        if (!$where
144 144
             || in_array($where["type"], ["NotNull", "Null"])
145 145
         ) {
146 146
             return "";
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         $values = $this->getValuesFromWhere($where);
150 150
         $values = $this->getValuesFromBindings($where, $values);
151 151
 
152
-        return "_" . $values;
152
+        return "_".$values;
153 153
     }
154 154
 
155 155
     protected function getValuesFromWhere(array $where) : string
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
             $this->currentBinding++;
180 180
 
181 181
             if ($where["type"] === "between") {
182
-                $values .= "_" . $this->query->bindings["where"][$this->currentBinding];
182
+                $values .= "_".$this->query->bindings["where"][$this->currentBinding];
183 183
                 $this->currentBinding++;
184 184
             }
185 185
         }
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
 
196 196
     protected function getWhereClauses(array $wheres = []) : string
197 197
     {
198
-        return "" . $this->getWheres($wheres)
199
-            ->reduce(function ($carry, $where) {
198
+        return "".$this->getWheres($wheres)
199
+            ->reduce(function($carry, $where) {
200 200
                 $value = $carry;
201 201
                 $value .= $this->getNestedClauses($where);
202 202
                 $value .= $this->getColumnClauses($where);
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
 
211 211
     protected function getNestedClauses(array $where) : string
212 212
     {
213
-        if (! in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
213
+        if (!in_array($where["type"], ["Exists", "Nested", "NotExists"])) {
214 214
             return "";
215 215
         }
216 216
 
217
-        return "-" . strtolower($where["type"]) . $this->getWhereClauses($where["query"]->wheres);
217
+        return "-".strtolower($where["type"]).$this->getWhereClauses($where["query"]->wheres);
218 218
     }
219 219
 
220 220
     protected function getColumnClauses(array $where) : string
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
     protected function getInAndNotInClauses(array $where) : string
230 230
     {
231
-        if (! in_array($where["type"], ["In", "NotIn", "InRaw"])) {
231
+        if (!in_array($where["type"], ["In", "NotIn", "InRaw"])) {
232 232
             return "";
233 233
         }
234 234
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
             $this->currentBinding += count($where["values"]);
241 241
         }
242 242
 
243
-        if (! is_numeric($subquery) && ! is_numeric(str_replace("_", "", $subquery))) {
243
+        if (!is_numeric($subquery) && !is_numeric(str_replace("_", "", $subquery))) {
244 244
             try {
245 245
                 $subquery = Uuid::fromBytes($subquery);
246 246
                 $values = $this->recursiveImplode([$subquery], "_");
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
                 continue;
279 279
             }
280 280
 
281
-            $result .= $glue . $value;
281
+            $result .= $glue.$value;
282 282
         }
283 283
 
284 284
         return $result;
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 
287 287
     protected function getRawClauses(array $where) : string
288 288
     {
289
-        if (! in_array($where["type"], ["raw"])) {
289
+        if (!in_array($where["type"], ["raw"])) {
290 290
             return "";
291 291
         }
292 292
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
         $clause = "_{$where["boolean"]}";
295 295
 
296 296
         while (count($queryParts) > 1) {
297
-            $clause .= "_" . array_shift($queryParts);
297
+            $clause .= "_".array_shift($queryParts);
298 298
             $clause .= $this->query->bindings["where"][$this->currentBinding];
299 299
             $this->currentBinding++;
300 300
         }
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
         $lastPart = array_shift($queryParts);
303 303
 
304 304
         if ($lastPart) {
305
-            $clause .= "_" . $lastPart;
305
+            $clause .= "_".$lastPart;
306 306
         }
307 307
 
308
-        return "-" . str_replace(" ", "_", $clause);
308
+        return "-".str_replace(" ", "_", $clause);
309 309
     }
310 310
 
311 311
     protected function getOtherClauses(array $where) : string
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
             return "";
342 342
         }
343 343
 
344
-        return $eagerLoads->keys()->reduce(function ($carry, $related) {
345
-            if (! method_exists($this->model, $related)) {
344
+        return $eagerLoads->keys()->reduce(function($carry, $related) {
345
+            if (!method_exists($this->model, $related)) {
346 346
                 return "{$carry}-{$related}";
347 347
             }
348 348
 
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 
357 357
     protected function getBindingsSlug() : string
358 358
     {
359
-        if (! method_exists($this->model, 'query')) {
359
+        if (!method_exists($this->model, 'query')) {
360 360
             return '';
361 361
         }
362 362
         
Please login to merge, or discard this patch.
src/Providers/Service.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
     public function boot()
16 16
     {
17
-        $configPath = __DIR__ . '/../../config/laravel-model-caching.php';
17
+        $configPath = __DIR__.'/../../config/laravel-model-caching.php';
18 18
         $this->mergeConfigFrom($configPath, 'laravel-model-caching');
19 19
         $this->commands([
20 20
             Clear::class,
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
     public function register()
29 29
     {
30
-        if (! class_exists('GeneaLabs\LaravelModelCaching\EloquentBuilder')) {
30
+        if (!class_exists('GeneaLabs\LaravelModelCaching\EloquentBuilder')) {
31 31
             class_alias(
32 32
                 ModelCaching::builder(),
33 33
                 'GeneaLabs\LaravelModelCaching\EloquentBuilder'
Please login to merge, or discard this patch.
tests/Nova/BelongsToManyTest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
         $beforeBook->title = 'new foo';
16 16
         $beforeBook->save();
17 17
 
18
-        $this->postJson('nova-api/books/' . $beforeBook->id . '/attach/stores' , [
18
+        $this->postJson('nova-api/books/'.$beforeBook->id.'/attach/stores', [
19 19
             'stores' => $beforeStore->id,
20 20
             'viaRelationship' => 'stores'
21 21
         ]);
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         $beforeBooks = $beforeStore->books;
48 48
         $beforeBook = $beforeBooks->first();
49 49
 
50
-        $this->deleteJson('/nova-api/stores/detach?viaResource=books&viaResourceId=' . $beforeBook->id  . '&viaRelationship=stores' , [
50
+        $this->deleteJson('/nova-api/stores/detach?viaResource=books&viaResourceId='.$beforeBook->id.'&viaRelationship=stores', [
51 51
             'resources' => [$beforeStore->id],
52 52
         ]);
53 53
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $beforeStore = Store::with(['books'])->get()->first();
67 67
         $beforeBook = $beforeStore->books->first();
68 68
 
69
-        $this->putJson('nova-api/books/' . $beforeBook->id, [
69
+        $this->putJson('nova-api/books/'.$beforeBook->id, [
70 70
             'title' => 'foo',
71 71
         ]);
72 72
 
Please login to merge, or discard this patch.
tests/Nova/UpdateTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
         $beforeAuthors = (new Author)->get();
11 11
         $author = $beforeAuthors->first();
12 12
 
13
-        $this->putJson('nova-api/authors/' . $author->id, [
13
+        $this->putJson('nova-api/authors/'.$author->id, [
14 14
             'name' => 'foo',
15 15
             'email' => '[email protected]',
16 16
         ]);
Please login to merge, or discard this patch.
tests/CreatesApplication.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -31,20 +31,20 @@  discard block
 block discarded – undo
31 31
 
32 32
         $this->setUpBaseLineSqlLiteDatabase();
33 33
 
34
-        $databasePath = __DIR__ . "/database";
34
+        $databasePath = __DIR__."/database";
35 35
         $this->testingSqlitePath = "{$databasePath}/";
36 36
         $baselinePath = "{$databasePath}/baseline.sqlite";
37 37
         $testingPath = "{$databasePath}/testing.sqlite";
38 38
 
39
-        ! file_exists($testingPath)
39
+        !file_exists($testingPath)
40 40
             ?: unlink($testingPath);
41 41
         copy($baselinePath, $testingPath);
42 42
 
43
-        require(__DIR__ . '/routes/web.php');
43
+        require(__DIR__.'/routes/web.php');
44 44
 
45
-        $this->withFactories(__DIR__ . '/database/factories');
45
+        $this->withFactories(__DIR__.'/database/factories');
46 46
 
47
-        view()->addLocation(__DIR__ . '/resources/views', 'laravel-model-caching');
47
+        view()->addLocation(__DIR__.'/resources/views', 'laravel-model-caching');
48 48
 
49 49
         $this->cache = app('cache')
50 50
             ->store(config('laravel-model-caching.store'));
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
         self::$baseLineDatabaseMigrated = true;
71 71
 
72
-        $file = __DIR__ . '/database/baseline.sqlite';
72
+        $file = __DIR__.'/database/baseline.sqlite';
73 73
         $this->app['config']->set('database.default', 'baseline');
74 74
         $this->app['config']->set('database.connections.baseline', [
75 75
             'driver' => 'sqlite',
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
             "foreign_key_constraints" => false,
80 80
         ]);
81 81
 
82
-        ! file_exists($file)
82
+        !file_exists($file)
83 83
             ?: unlink($file);
84 84
         touch($file);
85 85
 
86
-        $this->withFactories(__DIR__ . '/database/factories');
87
-        $this->loadMigrationsFrom(__DIR__ . '/database/migrations');
86
+        $this->withFactories(__DIR__.'/database/factories');
87
+        $this->loadMigrationsFrom(__DIR__.'/database/migrations');
88 88
 
89 89
         Artisan::call('db:seed', [
90 90
             '--class' => 'DatabaseSeeder',
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         $app['config']->set('database.default', 'testing');
100 100
         $app['config']->set('database.connections.testing', [
101 101
             'driver' => 'sqlite',
102
-            'database' => __DIR__ . '/database/testing.sqlite',
102
+            'database' => __DIR__.'/database/testing.sqlite',
103 103
             'prefix' => '',
104 104
             "foreign_key_constraints" => false,
105 105
         ]);
Please login to merge, or discard this patch.
tests/database/seeds/DatabaseSeeder.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,18 +42,18 @@  discard block
 block discarded – undo
42 42
                 "commentable_id" => $post->id,
43 43
                 "commentable_type" => Post::class,
44 44
             ])
45
-            ->each(function ($comment) {
45
+            ->each(function($comment) {
46 46
                 (new Comment)->create([
47 47
                     "commentable_id" => $comment->commentable_id,
48 48
                     "commentable_type" => UncachedPost::class,
49 49
                     "description" => $comment->description,
50
-                    "subject" => $comment->subject . ' - uncached post',
50
+                    "subject" => $comment->subject.' - uncached post',
51 51
                 ]);
52 52
             });
53 53
         $publishers = factory(Publisher::class, 10)->create();
54 54
         (new Author)->observe(AuthorObserver::class);
55 55
         factory(Author::class, 10)->create()
56
-            ->each(function ($author) use ($publishers) {
56
+            ->each(function($author) use ($publishers) {
57 57
                 $profile = factory(Profile::class)
58 58
                     ->make();
59 59
                 $profile->author_id = $author->id;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                         "author_id" => $author->id,
64 64
                         "publisher_id" => $publishers[rand(0, 9)]->id,
65 65
                     ])
66
-                    ->each(function ($book) use ($author, $publishers) {
66
+                    ->each(function($book) use ($author, $publishers) {
67 67
                         factory(Printer::class)->create([
68 68
                             "book_id" => $book->id,
69 69
                         ]);
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 
76 76
         $bookIds = (new Book)->all()->pluck('id');
77 77
         factory(Store::class, 10)->create()
78
-            ->each(function ($store) use ($bookIds) {
78
+            ->each(function($store) use ($bookIds) {
79 79
                 $store->books()->sync(rand($bookIds->min(), $bookIds->max()));
80 80
             });
81 81
     }
Please login to merge, or discard this patch.
tests/database/factories/UserFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Supplier;
5 5
 use GeneaLabs\LaravelModelCaching\Tests\Fixtures\User;
6 6
 
7
-$factory->define(User::class, function (Faker $faker) {
7
+$factory->define(User::class, function(Faker $faker) {
8 8
     return [
9 9
         'name' => $faker->name,
10 10
         "supplier_id" => factory(Supplier::class)->create()->id,
Please login to merge, or discard this patch.
tests/database/factories/HistoryFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 use GeneaLabs\LaravelModelCaching\Tests\Fixtures\History;
5 5
 use GeneaLabs\LaravelModelCaching\Tests\Fixtures\User;
6 6
 
7
-$factory->define(History::class, function (Faker $faker) {
7
+$factory->define(History::class, function(Faker $faker) {
8 8
     return [
9 9
         'name' => $faker->name,
10 10
         "user_id" => factory(User::class)->create()->id,
Please login to merge, or discard this patch.