@@ -1,6 +1,6 @@  | 
                                                    ||
| 1 | 1 | <?php  | 
                                                        
| 2 | 2 | |
| 3 | -if (! function_exists('visits')) | 
                                                        |
| 3 | +if (!function_exists('visits')) | 
                                                        |
| 4 | 4 |  { | 
                                                        
| 5 | 5 | function visits($subject, $tag = 'visits')  | 
                                                        
| 6 | 6 |      { | 
                                                        
@@ -17,7 +17,7 @@ discard block  | 
                                                    ||
| 17 | 17 | $cachedList = $this->cachedList($limit, $cacheKey);  | 
                                                        
| 18 | 18 | $visitsIds = $this->getVisitsIds($limit, $this->keys->visits, $isLow);  | 
                                                        
| 19 | 19 | |
| 20 | -        if($visitsIds === $cachedList->pluck($this->keys->primary)->toArray() && ! $this->fresh) { | 
                                                        |
| 20 | +        if ($visitsIds === $cachedList->pluck($this->keys->primary)->toArray() && !$this->fresh) { | 
                                                        |
| 21 | 21 | return $cachedList;  | 
                                                        
| 22 | 22 | }  | 
                                                        
| 23 | 23 | |
@@ -90,9 +90,9 @@ discard block  | 
                                                    ||
| 90 | 90 | |
| 91 | 91 | return ($this->subject)::whereIn($this->keys->primary, $visitsIds)  | 
                                                        
| 92 | 92 | ->get()  | 
                                                        
| 93 | -                ->sortBy(function ($subject) use ($visitsIds) { | 
                                                        |
| 93 | +                ->sortBy(function($subject) use ($visitsIds) { | 
                                                        |
| 94 | 94 |                      return array_search($subject->{$this->keys->primary}, $visitsIds); | 
                                                        
| 95 | -                })->each(function ($subject) use ($cacheKey) { | 
                                                        |
| 95 | +                })->each(function($subject) use ($cacheKey) { | 
                                                        |
| 96 | 96 | $this->redis->rpush($cacheKey, serialize($subject));  | 
                                                        
| 97 | 97 | });  | 
                                                        
| 98 | 98 | }  | 
                                                        
@@ -58,11 +58,11 @@  | 
                                                    ||
| 58 | 58 | */  | 
                                                        
| 59 | 59 | protected function xHoursPeriod($period)  | 
                                                        
| 60 | 60 |      { | 
                                                        
| 61 | -        return collect(range(1, 12))->map(function ($hour) { | 
                                                        |
| 61 | +        return collect(range(1, 12))->map(function($hour) { | 
                                                        |
| 62 | 62 | return ['method' => $hour . 'hours', 'hours' => $hour];  | 
                                                        
| 63 | 63 |              })->where('method', $period) | 
                                                        
| 64 | 64 |              ->pluck('hours') | 
                                                        
| 65 | -            ->map(function ($hours) { | 
                                                        |
| 65 | +            ->map(function($hours) { | 
                                                        |
| 66 | 66 | return Carbon::now()->endOfxHours($hours);  | 
                                                        
| 67 | 67 | })  | 
                                                        
| 68 | 68 | ->first();  | 
                                                        
@@ -77,7 +77,7 @@ discard block  | 
                                                    ||
| 77 | 77 | */  | 
                                                        
| 78 | 78 | public function by($subject)  | 
                                                        
| 79 | 79 |      { | 
                                                        
| 80 | -        if($subject instanceof Model) { | 
                                                        |
| 80 | +        if ($subject instanceof Model) { | 
                                                        |
| 81 | 81 |              $this->keys->append($this->keys->modelName($subject), $subject->{$subject->getKeyName()}); | 
                                                        
| 82 | 82 |          } else if (is_array($subject)) { | 
                                                        
| 83 | 83 | $this->keys->append(array_keys($subject)[0], array_first($subject));  | 
                                                        
@@ -106,7 +106,7 @@ discard block  | 
                                                    ||
| 106 | 106 | */  | 
                                                        
| 107 | 107 | public function recordedIp()  | 
                                                        
| 108 | 108 |      { | 
                                                        
| 109 | - return ! $this->redis->set($this->keys->ip(request()->ip()), true, 'EX', $this->ipSeconds, 'NX');  | 
                                                        |
| 109 | + return !$this->redis->set($this->keys->ip(request()->ip()), true, 'EX', $this->ipSeconds, 'NX');  | 
                                                        |
| 110 | 110 | }  | 
                                                        
| 111 | 111 | |
| 112 | 112 | /**  | 
                                                        
@@ -125,8 +125,7 @@ discard block  | 
                                                    ||
| 125 | 125 | |
| 126 | 126 | return intval(  | 
                                                        
| 127 | 127 | (!$this->keys->instanceOfModel) ?  | 
                                                        
| 128 | - $this->redis->get($this->keys->visits . '_total') :  | 
                                                        |
| 129 | - $this->redis->zscore($this->keys->visits, $this->keys->id)  | 
                                                        |
| 128 | + $this->redis->get($this->keys->visits . '_total') : $this->redis->zscore($this->keys->visits, $this->keys->id)  | 
                                                        |
| 130 | 129 | );  | 
                                                        
| 131 | 130 | }  | 
                                                        
| 132 | 131 | |
@@ -18,20 +18,20 @@ discard block  | 
                                                    ||
| 18 | 18 |              __DIR__ . '/config/visits.php' => config_path('visits.php'), | 
                                                        
| 19 | 19 | ], 'config');  | 
                                                        
| 20 | 20 | |
| 21 | -        Carbon::macro('endOfxHours', function ($xhours) { | 
                                                        |
| 21 | +        Carbon::macro('endOfxHours', function($xhours) { | 
                                                        |
| 22 | 22 | |
| 23 | -            if($xhours > 12) { | 
                                                        |
| 23 | +            if ($xhours > 12) { | 
                                                        |
| 24 | 24 |                  throw new \Exception('12 is the maximum period in xHours feature'); | 
                                                        
| 25 | 25 | }  | 
                                                        
| 26 | 26 | |
| 27 | 27 | $hour = collect(range(1, 24 / $xhours))  | 
                                                        
| 28 | -                ->map(function ($hour) use ($xhours) { | 
                                                        |
| 28 | +                ->map(function($hour) use ($xhours) { | 
                                                        |
| 29 | 29 | return $hour * $xhours;  | 
                                                        
| 30 | -                })->first(function ($hour) { | 
                                                        |
| 30 | +                })->first(function($hour) { | 
                                                        |
| 31 | 31 | return $hour >= $this->hour;  | 
                                                        
| 32 | 32 | });  | 
                                                        
| 33 | 33 | |
| 34 | - return $this->setTime($hour , 59, 59);  | 
                                                        |
| 34 | + return $this->setTime($hour, 59, 59);  | 
                                                        |
| 35 | 35 | });  | 
                                                        
| 36 | 36 | }  | 
                                                        
| 37 | 37 | |
@@ -43,7 +43,7 @@ discard block  | 
                                                    ||
| 43 | 43 | public function register()  | 
                                                        
| 44 | 44 |      { | 
                                                        
| 45 | 45 | $this->mergeConfigFrom(  | 
                                                        
| 46 | - __DIR__.'/config/visits.php', 'visits'  | 
                                                        |
| 46 | + __DIR__ . '/config/visits.php', 'visits'  | 
                                                        |
| 47 | 47 | );  | 
                                                        
| 48 | 48 | }  | 
                                                        
| 49 | 49 | }  |