Test Failed
Push — master ( e24dc8...83c9b1 )
by Nur
09:23
created
src/Console/LikeableRecountCommand.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
         DB::table(app(LikeCounterContract::class)->getTable())->insert($counters);
98 98
 
99
-        $this->info('All ['.$modelType.'] records likes has been recounted.');
99
+        $this->info('All [' . $modelType . '] records likes has been recounted.');
100 100
     }
101 101
 
102 102
     /**
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             $model = new $modelType;
116 116
             $modelType = $model->getMorphClass();
117 117
         } else {
118
-            if (! isset($morphMap[$modelType])) {
118
+            if (!isset($morphMap[$modelType])) {
119 119
                 throw new ModelInvalidException("[$modelType] class and morph map are not found.");
120 120
             }
121 121
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
             $model = new $modelClass;
124 124
         }
125 125
 
126
-        if (! $model instanceof LikeableContract) {
126
+        if (!$model instanceof LikeableContract) {
127 127
             throw new ModelInvalidException("[$modelType] not implements Likeable contract.");
128 128
         }
129 129
 
Please login to merge, or discard this patch.
src/Services/LikeableService.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
             'user_id' => $userId,
35 35
         ])->first();
36 36
 
37
-        if (! $like) {
37
+        if (!$like) {
38 38
             $likeable->likes()->create([
39 39
                 'user_id' => $userId,
40 40
                 'type_id' => $this->getLikeTypeId($type),
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
             'type_id' => $this->getLikeTypeId($type),
74 74
         ])->first();
75 75
 
76
-        if (! $like) {
76
+        if (!$like) {
77 77
             return;
78 78
         }
79 79
 
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
             $userId = $this->loggedInUserId();
124 124
         }
125 125
 
126
-        if (! $userId) {
126
+        if (!$userId) {
127 127
             return false;
128 128
         }
129 129
 
130 130
         $typeId = $this->getLikeTypeId($type);
131 131
 
132 132
         $exists = $this->hasLikeOrDislikeInLoadedRelation($likeable, $typeId, $userId);
133
-        if (! is_null($exists)) {
133
+        if (!is_null($exists)) {
134 134
             return $exists;
135 135
         }
136 136
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     {
151 151
         $counter = $likeable->likesCounter()->first();
152 152
 
153
-        if (! $counter) {
153
+        if (!$counter) {
154 154
             return;
155 155
         }
156 156
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     {
168 168
         $counter = $likeable->likesCounter()->first();
169 169
 
170
-        if (! $counter) {
170
+        if (!$counter) {
171 171
             $counter = $likeable->likesCounter()->create([
172 172
                 'count' => 0,
173 173
                 'type_id' => LikeType::LIKE,
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
     {
188 188
         $counter = $likeable->dislikesCounter()->first();
189 189
 
190
-        if (! $counter) {
190
+        if (!$counter) {
191 191
             return;
192 192
         }
193 193
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
     {
205 205
         $counter = $likeable->dislikesCounter()->first();
206 206
 
207
-        if (! $counter) {
207
+        if (!$counter) {
208 208
             $counter = $likeable->dislikesCounter()->create([
209 209
                 'count' => 0,
210 210
                 'type_id' => LikeType::DISLIKE,
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
         /** @var \Illuminate\Database\Eloquent\Builder $counters */
235 235
         $counters = app(LikeCounterContract::class)->where('likeable_type', $likeableType);
236
-        if (! is_null($type)) {
236
+        if (!is_null($type)) {
237 237
             $counters->where('type_id', $this->getLikeTypeId($type));
238 238
         }
239 239
         $counters->delete();
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
     {
308 308
         $userId = $this->getLikerUserId($userId);
309 309
 
310
-        return $query->whereHas('likesAndDislikes', function (Builder $innerQuery) use ($type, $userId) {
310
+        return $query->whereHas('likesAndDislikes', function(Builder $innerQuery) use ($type, $userId) {
311 311
             $innerQuery->where('user_id', $userId);
312 312
             $innerQuery->where('type_id', $this->getLikeTypeId($type));
313 313
         });
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
326 326
         $likeable = $query->getModel();
327 327
 
328 328
         return $query
329
-            ->select($likeable->getTable().'.*', 'like_counter.count')
330
-            ->leftJoin('like_counter', function (JoinClause $join) use ($likeable, $likeType) {
329
+            ->select($likeable->getTable() . '.*', 'like_counter.count')
330
+            ->leftJoin('like_counter', function(JoinClause $join) use ($likeable, $likeType) {
331 331
                 $join
332 332
                     ->on('like_counter.likeable_id', '=', "{$likeable->getTable()}.{$likeable->getKeyName()}")
333 333
                     ->where('like_counter.likeable_type', '=', $likeable->getMorphClass())
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
             ])
358 358
             ->where('likeable_type', $likeableType);
359 359
 
360
-        if (! is_null($likeType)) {
360
+        if (!is_null($likeType)) {
361 361
             $likesCount->where('type_id', $this->getLikeTypeId($likeType));
362 362
         }
363 363
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
             $userId = $this->loggedInUserId();
381 381
         }
382 382
 
383
-        if (! $userId) {
383
+        if (!$userId) {
384 384
             throw new LikerNotDefinedException();
385 385
         }
386 386
 
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
     protected function getLikeTypeId($type)
410 410
     {
411 411
         $type = strtoupper($type);
412
-        if (! defined("\\Turahe\\Likeable\\Enums\\LikeType::{$type}")) {
412
+        if (!defined("\\Turahe\\Likeable\\Enums\\LikeType::{$type}")) {
413 413
             throw new LikeTypeInvalidException("Like type `{$type}` not exist");
414 414
         }
415 415
 
@@ -439,11 +439,11 @@  discard block
 block discarded – undo
439 439
         $relations = $this->likeTypeRelations($typeId);
440 440
 
441 441
         foreach ($relations as $relation) {
442
-            if (! $likeable->relationLoaded($relation)) {
442
+            if (!$likeable->relationLoaded($relation)) {
443 443
                 continue;
444 444
             }
445 445
 
446
-            return $likeable->{$relation}->contains(function ($item) use ($userId, $typeId) {
446
+            return $likeable->{$relation}->contains(function($item) use ($userId, $typeId) {
447 447
                 return $item->user_id == $userId && $item->type_id === $typeId;
448 448
             });
449 449
         }
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
             ],
473 473
         ];
474 474
 
475
-        if (! isset($relations[$type])) {
475
+        if (!isset($relations[$type])) {
476 476
             throw new LikeTypeInvalidException("Like type `{$type}` not supported");
477 477
         }
478 478
 
Please login to merge, or discard this patch.
src/Observers/ModelObserver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
      */
18 18
     public function deleted(LikeableContract $likeable)
19 19
     {
20
-        if (! $this->removeLikesOnDelete($likeable)) {
20
+        if (!$this->removeLikesOnDelete($likeable)) {
21 21
             return;
22 22
         }
23 23
 
Please login to merge, or discard this patch.
src/LikeableServiceProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -81,12 +81,12 @@
 block discarded – undo
81 81
      */
82 82
     protected function registerPublishes()
83 83
     {
84
-        $databasePath = __DIR__.'/../migrations';
84
+        $databasePath = __DIR__ . '/../migrations';
85 85
         $this->loadMigrationsFrom($databasePath);
86 86
 
87 87
         if ($this->app->runningInConsole()) {
88 88
             $this->publishes([
89
-                __DIR__.'./../migrations' => database_path('migrations'),
89
+                __DIR__ . './../migrations' => database_path('migrations'),
90 90
             ], 'migrations');
91 91
         }
92 92
     }
Please login to merge, or discard this patch.