Completed
Branch master (120ad6)
by bader
03:52 queued 01:39
created
src/Visits.php 1 patch
Spacing   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function __get($attribute)
68 68
     {
69
-        if($this->keys->instanceOfModel && $relation = $this->subject->$attribute) {
69
+        if ($this->keys->instanceOfModel && $relation = $this->subject->$attribute) {
70 70
             $this->keys->append($attribute, $relation->{$relation->getKeyName()});
71 71
         }
72 72
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      */
80 80
     public function by($subject)
81 81
     {
82
-        if($subject instanceof Model) {
82
+        if ($subject instanceof Model) {
83 83
             $this->keys->append(strtolower(str_singular(class_basename(get_class($subject)))),
84 84
                 $subject->{$subject->getKeyName()});
85 85
         } else if (is_array($subject)) {
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
         $cachedList = $this->cachedList($limit, $cacheKey);
234 234
         $visitsIds = $this->getVisits($limit, $this->keys->visits, $isLow);
235 235
 
236
-        if($visitsIds === $cachedList->pluck('id')->toArray() && ! $this->fresh) {
236
+        if ($visitsIds === $cachedList->pluck('id')->toArray() && !$this->fresh) {
237 237
             return $cachedList;
238 238
         }
239 239
 
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
      */
289 289
     public function recordedIp()
290 290
     {
291
-        return ! $this->redis->set($this->keys->ip(request()->ip()), true, 'EX', $this->ipSeconds, 'NX');
291
+        return !$this->redis->set($this->keys->ip(request()->ip()), true, 'EX', $this->ipSeconds, 'NX');
292 292
     }
293 293
 
294 294
     /**
@@ -307,8 +307,7 @@  discard block
 block discarded – undo
307 307
 
308 308
         return intval(
309 309
             (!$this->keys->instanceOfModel) ?
310
-                $this->redis->get($this->keys->visits . '_total') :
311
-                $this->redis->zscore($this->keys->visits, $this->keys->id)
310
+                $this->redis->get($this->keys->visits . '_total') : $this->redis->zscore($this->keys->visits, $this->keys->id)
312 311
         );
313 312
     }
314 313
 
@@ -371,7 +370,7 @@  discard block
 block discarded – undo
371 370
             $this->redis->incrby($this->keys->visits . '_total', $inc);
372 371
 
373 372
             foreach (['country', 'refer', 'periods'] as $method) {
374
-                $$method && $this->{'record'. studly_case($method)}($inc);
373
+                $$method && $this->{'record' . studly_case($method)}($inc);
375 374
             }
376 375
         }
377 376
     }
@@ -431,9 +430,9 @@  discard block
 block discarded – undo
431 430
 
432 431
             return ($this->subject)::whereIn($this->keys->primary, $visitsIds)
433 432
                 ->get()
434
-                ->sortBy(function ($subject) use ($visitsIds) {
433
+                ->sortBy(function($subject) use ($visitsIds) {
435 434
                     return array_search($subject->{$this->keys->primary}, $visitsIds);
436
-                })->each(function ($subject) use ($cacheKey) {
435
+                })->each(function($subject) use ($cacheKey) {
437 436
                     $this->redis->rpush($cacheKey, serialize($subject));
438 437
                 });
439 438
         }
Please login to merge, or discard this patch.