Completed
Pull Request — master (#409)
by Mike
41s
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/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.
tests/database/factories/UncachedAuthorFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 use Faker\Generator as Faker;
4 4
 use GeneaLabs\LaravelModelCaching\Tests\Fixtures\UncachedAuthor;
5 5
 
6
-$factory->define(UncachedAuthor::class, function (Faker $faker) {
6
+$factory->define(UncachedAuthor::class, function(Faker $faker) {
7 7
     return [
8 8
         'name' => $faker->name,
9 9
         'email' => $faker->unique()->safeEmail,
Please login to merge, or discard this patch.