@@ -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 | { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | public function get(string $key, ?string $member = null) |
67 | 67 | { |
68 | 68 | if(! empty($member) || is_numeric($member)) { |
69 | - return $this->model->where(['primary_key' => $this->prefix.$key, 'secondary_key' => $member]) |
|
69 | + return $this->model->where(['primary_key' => $this->prefix.$key, 'secondary_key' => $member]) |
|
70 | 70 | ->where(function($q) { |
71 | 71 | return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at'); |
72 | 72 | }) |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | { |
194 | 194 | $time = \Carbon\Carbon::now()->addSeconds($time); |
195 | 195 | |
196 | - return $this->model->where(['primary_key' => $this->prefix.$key]) |
|
196 | + return $this->model->where(['primary_key' => $this->prefix.$key]) |
|
197 | 197 | ->where(function($q) { |
198 | 198 | return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at'); |
199 | 199 | }) |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | |
27 | 27 | public function increment(string $key, int $value, ?string $member = null): bool |
28 | 28 | { |
29 | - if (! empty($member) || is_numeric($member)) { |
|
30 | - $row = $this->model->firstOrNew(['primary_key' => $this->prefix.$key, 'secondary_key' => $member]); |
|
29 | + if (!empty($member) || is_numeric($member)) { |
|
30 | + $row = $this->model->firstOrNew(['primary_key' => $this->prefix . $key, 'secondary_key' => $member]); |
|
31 | 31 | } else { |
32 | - $row = $this->model->firstOrNew(['primary_key' => $this->prefix.$key, 'secondary_key' => null]); |
|
32 | + $row = $this->model->firstOrNew(['primary_key' => $this->prefix . $key, 'secondary_key' => null]); |
|
33 | 33 | } |
34 | 34 | |
35 | - if($row->expired_at !== null && \Carbon\Carbon::now()->gt($row->expired_at)) { |
|
35 | + if ($row->expired_at !== null && \Carbon\Carbon::now()->gt($row->expired_at)) { |
|
36 | 36 | $row->score = $value; |
37 | 37 | $row->expired_at = null; |
38 | 38 | } else { |
@@ -49,30 +49,30 @@ discard block |
||
49 | 49 | |
50 | 50 | public function delete($key, ?string $member = null): bool |
51 | 51 | { |
52 | - if(is_array($key)) { |
|
52 | + if (is_array($key)) { |
|
53 | 53 | array_walk($key, function($item) { |
54 | 54 | $this->delete($item); |
55 | 55 | }); |
56 | 56 | return true; |
57 | 57 | } |
58 | 58 | |
59 | - if(! empty($member) || is_numeric($member)) { |
|
60 | - return $this->model->where(['primary_key' => $this->prefix.$key, 'secondary_key' => $member])->delete(); |
|
59 | + if (!empty($member) || is_numeric($member)) { |
|
60 | + return $this->model->where(['primary_key' => $this->prefix . $key, 'secondary_key' => $member])->delete(); |
|
61 | 61 | } else { |
62 | - return $this->model->where(['primary_key' => $this->prefix.$key])->delete(); |
|
62 | + return $this->model->where(['primary_key' => $this->prefix . $key])->delete(); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | 66 | public function get(string $key, ?string $member = null) |
67 | 67 | { |
68 | - if(! empty($member) || is_numeric($member)) { |
|
69 | - return $this->model->where(['primary_key' => $this->prefix.$key, 'secondary_key' => $member]) |
|
68 | + if (!empty($member) || is_numeric($member)) { |
|
69 | + return $this->model->where(['primary_key' => $this->prefix . $key, 'secondary_key' => $member]) |
|
70 | 70 | ->where(function($q) { |
71 | 71 | return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at'); |
72 | 72 | }) |
73 | 73 | ->value('score'); |
74 | 74 | } else { |
75 | - return $this->model->where(['primary_key' => $this->prefix.$key, 'secondary_key' => null]) |
|
75 | + return $this->model->where(['primary_key' => $this->prefix . $key, 'secondary_key' => null]) |
|
76 | 76 | ->where(function($q) { |
77 | 77 | return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at'); |
78 | 78 | }) |
@@ -82,15 +82,15 @@ discard block |
||
82 | 82 | |
83 | 83 | public function set(string $key, $value, ?string $member = null): bool |
84 | 84 | { |
85 | - if(! empty($member) || is_numeric($member)) { |
|
85 | + if (!empty($member) || is_numeric($member)) { |
|
86 | 86 | return $this->model->create([ |
87 | - 'primary_key' => $this->prefix.$key, |
|
87 | + 'primary_key' => $this->prefix . $key, |
|
88 | 88 | 'secondary_key' => $member, |
89 | 89 | 'score' => $value, |
90 | 90 | ]) instanceof Model; |
91 | 91 | } else { |
92 | 92 | return $this->model->create([ |
93 | - 'primary_key' => $this->prefix.$key, |
|
93 | + 'primary_key' => $this->prefix . $key, |
|
94 | 94 | 'score' => $value, |
95 | 95 | ]) instanceof Model; |
96 | 96 | } |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | { |
101 | 101 | $results = []; |
102 | 102 | |
103 | - if($word == '*') { |
|
103 | + if ($word == '*') { |
|
104 | 104 | $results = $this->model |
105 | 105 | ->where(function($q) { |
106 | 106 | return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at'); |
107 | 107 | }) |
108 | 108 | ->pluck('primary_key'); |
109 | 109 | } else { |
110 | - $results = $this->model->where('primary_key', 'like', $this->prefix.str_replace('*', '%', $word)) |
|
110 | + $results = $this->model->where('primary_key', 'like', $this->prefix . str_replace('*', '%', $word)) |
|
111 | 111 | ->where(function($q) { |
112 | 112 | return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at'); |
113 | 113 | }) |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | public function flatList(string $key, int $limit = -1): array |
130 | 130 | { |
131 | 131 | return array_slice( |
132 | - $this->model->where(['primary_key' => $this->prefix.$key, 'secondary_key' => null]) |
|
132 | + $this->model->where(['primary_key' => $this->prefix . $key, 'secondary_key' => null]) |
|
133 | 133 | ->where(function($q) { |
134 | 134 | return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at'); |
135 | 135 | }) |
@@ -139,22 +139,22 @@ discard block |
||
139 | 139 | |
140 | 140 | public function addToFlatList(string $key, $value): bool |
141 | 141 | { |
142 | - $row = $this->model->firstOrNew(['primary_key' => $this->prefix.$key, 'secondary_key' => null]); |
|
142 | + $row = $this->model->firstOrNew(['primary_key' => $this->prefix . $key, 'secondary_key' => null]); |
|
143 | 143 | |
144 | - if($row->expired_at !== null && \Carbon\Carbon::now()->gt($row->expired_at)) { |
|
144 | + if ($row->expired_at !== null && \Carbon\Carbon::now()->gt($row->expired_at)) { |
|
145 | 145 | $row->list = (array) $value; |
146 | 146 | $row->expired_at = null; |
147 | 147 | } else { |
148 | 148 | $row->list = array_merge($row->list ?? [], (array) $value); |
149 | 149 | } |
150 | 150 | |
151 | - $row->score = $row->score ?? 0; |
|
151 | + $row->score = $row->score ?? 0; |
|
152 | 152 | return (bool) $row->save(); |
153 | 153 | } |
154 | 154 | |
155 | 155 | public function valueList(string $key, int $limit = -1, bool $orderByAsc = false, bool $withValues = false): array |
156 | 156 | { |
157 | - $rows = $this->model->where('primary_key', $this->prefix.$key) |
|
157 | + $rows = $this->model->where('primary_key', $this->prefix . $key) |
|
158 | 158 | ->where(function($q) { |
159 | 159 | return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at'); |
160 | 160 | }) |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | ->whereNotNull('secondary_key') |
163 | 163 | ->orderBy('score', $orderByAsc ? 'asc' : 'desc') |
164 | 164 | ->when($limit > -1, function($q) use($limit) { |
165 | - return $q->limit($limit+1); |
|
165 | + return $q->limit($limit + 1); |
|
166 | 166 | })->pluck('score', 'secondary_key') ?? \Illuminate\Support\Collection::make(); |
167 | 167 | |
168 | 168 | return $withValues ? $rows->toArray() : array_keys($rows->toArray()); |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | |
171 | 171 | public function exists(string $key): bool |
172 | 172 | { |
173 | - return $this->model->where(['primary_key' => $this->prefix.$key, 'secondary_key' => null]) |
|
173 | + return $this->model->where(['primary_key' => $this->prefix . $key, 'secondary_key' => null]) |
|
174 | 174 | ->where(function($q) { |
175 | 175 | return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at'); |
176 | 176 | }) |
@@ -179,13 +179,13 @@ discard block |
||
179 | 179 | |
180 | 180 | public function timeLeft(string $key): int |
181 | 181 | { |
182 | - $expired_at = $this->model->where(['primary_key' => $this->prefix.$key])->value('expired_at'); |
|
182 | + $expired_at = $this->model->where(['primary_key' => $this->prefix . $key])->value('expired_at'); |
|
183 | 183 | |
184 | - if($expired_at === null) { |
|
184 | + if ($expired_at === null) { |
|
185 | 185 | return -2; |
186 | 186 | } |
187 | 187 | |
188 | - $ttl = $expired_at->timestamp - \Carbon\Carbon::now()->timestamp; |
|
188 | + $ttl = $expired_at->timestamp - \Carbon\Carbon::now()->timestamp; |
|
189 | 189 | return $ttl <= 0 ? -1 : $ttl; |
190 | 190 | } |
191 | 191 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | { |
194 | 194 | $time = \Carbon\Carbon::now()->addSeconds($time); |
195 | 195 | |
196 | - return $this->model->where(['primary_key' => $this->prefix.$key]) |
|
196 | + return $this->model->where(['primary_key' => $this->prefix . $key]) |
|
197 | 197 | ->where(function($q) { |
198 | 198 | return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at'); |
199 | 199 | }) |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | |
30 | 30 | public function increment(string $key, int $value, ?string $member = null): bool |
31 | 31 | { |
32 | - if (! empty($member) || is_numeric($member)) { |
|
33 | - $this->connection->zincrby($this->prefix.$key, $value, $member); |
|
32 | + if (!empty($member) || is_numeric($member)) { |
|
33 | + $this->connection->zincrby($this->prefix . $key, $value, $member); |
|
34 | 34 | } else { |
35 | - $this->connection->incrby($this->prefix.$key, $value); |
|
35 | + $this->connection->incrby($this->prefix . $key, $value); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // both methods returns integer and raise an excpetion in case of an error. |
@@ -46,35 +46,35 @@ discard block |
||
46 | 46 | |
47 | 47 | public function delete($key, ?string $member = null): bool |
48 | 48 | { |
49 | - if(is_array($key)) { |
|
49 | + if (is_array($key)) { |
|
50 | 50 | array_walk($key, function($item) { |
51 | 51 | $this->delete($item); |
52 | 52 | }); |
53 | 53 | return true; |
54 | 54 | } |
55 | 55 | |
56 | - if(! empty($member) || is_numeric($member)) { |
|
57 | - return $this->connection->zrem($this->prefix.$key, $member) > 0; |
|
56 | + if (!empty($member) || is_numeric($member)) { |
|
57 | + return $this->connection->zrem($this->prefix . $key, $member) > 0; |
|
58 | 58 | } else { |
59 | - return $this->connection->del($this->prefix.$key) > 0; |
|
59 | + return $this->connection->del($this->prefix . $key) > 0; |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | 63 | public function get(string $key, ?string $member = null) |
64 | 64 | { |
65 | - if(! empty($member) || is_numeric($member)) { |
|
66 | - return $this->connection->zscore($this->prefix.$key, $member); |
|
65 | + if (!empty($member) || is_numeric($member)) { |
|
66 | + return $this->connection->zscore($this->prefix . $key, $member); |
|
67 | 67 | } else { |
68 | - return $this->connection->get($this->prefix.$key); |
|
68 | + return $this->connection->get($this->prefix . $key); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | 72 | public function set(string $key, $value, ?string $member = null): bool |
73 | 73 | { |
74 | - if(! empty($member) || is_numeric($member)) { |
|
75 | - return $this->connection->zAdd($this->prefix.$key, $value, $member) > 0; |
|
74 | + if (!empty($member) || is_numeric($member)) { |
|
75 | + return $this->connection->zAdd($this->prefix . $key, $value, $member) > 0; |
|
76 | 76 | } else { |
77 | - return (bool) $this->connection->set($this->prefix.$key, $value); |
|
77 | + return (bool) $this->connection->set($this->prefix . $key, $value); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -88,39 +88,39 @@ discard block |
||
88 | 88 | |
89 | 89 | return $item; |
90 | 90 | }, |
91 | - $this->connection->keys($this->prefix.$word) ?? [] |
|
91 | + $this->connection->keys($this->prefix . $word) ?? [] |
|
92 | 92 | ); |
93 | 93 | } |
94 | 94 | |
95 | 95 | public function flatList(string $key, int $limit = -1): array |
96 | 96 | { |
97 | - return $this->connection->lrange($this->prefix.$key, 0, $limit); |
|
97 | + return $this->connection->lrange($this->prefix . $key, 0, $limit); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | public function addToFlatList(string $key, $value): bool |
101 | 101 | { |
102 | - return $this->connection->rpush($this->prefix.$key, $value) !== false; |
|
102 | + return $this->connection->rpush($this->prefix . $key, $value) !== false; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | public function valueList(string $key, int $limit = -1, bool $orderByAsc = false, bool $withValues = false): array |
106 | 106 | { |
107 | 107 | $range = $orderByAsc ? 'zrange' : 'zrevrange'; |
108 | 108 | |
109 | - return $this->connection->$range($this->prefix.$key, 0, $limit, ['withscores' => $withValues]); |
|
109 | + return $this->connection->$range($this->prefix . $key, 0, $limit, ['withscores' => $withValues]); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | public function exists(string $key): bool |
113 | 113 | { |
114 | - return (bool) $this->connection->exists($this->prefix.$key); |
|
114 | + return (bool) $this->connection->exists($this->prefix . $key); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | public function timeLeft(string $key): int |
118 | 118 | { |
119 | - return $this->connection->ttl($this->prefix.$key); |
|
119 | + return $this->connection->ttl($this->prefix . $key); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | public function setExpiration(string $key, int $time): bool |
123 | 123 | { |
124 | - return $this->connection->expire($this->prefix.$key, $time); |
|
124 | + return $this->connection->expire($this->prefix . $key, $time); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | \ No newline at end of file |
@@ -16,16 +16,16 @@ discard block |
||
16 | 16 | public function boot() |
17 | 17 | { |
18 | 18 | $this->publishes([ |
19 | - __DIR__.'/config/visits.php' => config_path('visits.php'), |
|
19 | + __DIR__ . '/config/visits.php' => config_path('visits.php'), |
|
20 | 20 | ], 'config'); |
21 | 21 | |
22 | - if (! class_exists('CreateVisitsTable')) { |
|
22 | + if (!class_exists('CreateVisitsTable')) { |
|
23 | 23 | $this->publishes([ |
24 | - __DIR__.'/../database/migrations/create_visits_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_visits_table.php'), |
|
24 | + __DIR__ . '/../database/migrations/create_visits_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_visits_table.php'), |
|
25 | 25 | ], 'migrations'); |
26 | 26 | } |
27 | 27 | |
28 | - Carbon::macro('endOfxHours', function ($xhours) { |
|
28 | + Carbon::macro('endOfxHours', function($xhours) { |
|
29 | 29 | if ($xhours > 12) { |
30 | 30 | throw new \Exception('12 is the maximum period in xHours feature'); |
31 | 31 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public function register() |
48 | 48 | { |
49 | 49 | $this->mergeConfigFrom( |
50 | - __DIR__.'/config/visits.php', |
|
50 | + __DIR__ . '/config/visits.php', |
|
51 | 51 | 'visits' |
52 | 52 | ); |
53 | 53 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $cachedList = $this->cachedList($limit, $cacheKey); |
20 | 20 | $visitsIds = $this->getVisitsIds($limit, $this->keys->visits, $orderByAsc); |
21 | 21 | |
22 | - if($visitsIds === $cachedList->pluck($this->keys->primary)->toArray() && ! $this->fresh) { |
|
22 | + if ($visitsIds === $cachedList->pluck($this->keys->primary)->toArray() && !$this->fresh) { |
|
23 | 23 | return $cachedList; |
24 | 24 | } |
25 | 25 | |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | |
102 | 102 | return ($this->subject)::whereIn($this->keys->primary, $visitsIds) |
103 | 103 | ->get() |
104 | - ->sortBy(function ($subject) use ($visitsIds) { |
|
104 | + ->sortBy(function($subject) use ($visitsIds) { |
|
105 | 105 | return array_search($subject->{$this->keys->primary}, $visitsIds); |
106 | - })->each(function ($subject) use ($cacheKey) { |
|
106 | + })->each(function($subject) use ($cacheKey) { |
|
107 | 107 | $this->connection->addToFlatList($cacheKey, serialize($subject)); |
108 | 108 | }); |
109 | 109 | } |
@@ -18,17 +18,17 @@ |
||
18 | 18 | |
19 | 19 | if ($this->noExpiration($periodKey)) { |
20 | 20 | $expireInSeconds = $this->newExpiration($period); |
21 | - $this->connection->increment($periodKey.'_total', 0); |
|
21 | + $this->connection->increment($periodKey . '_total', 0); |
|
22 | 22 | $this->connection->increment($periodKey, 0, 0); |
23 | 23 | $this->connection->setExpiration($periodKey, $expireInSeconds); |
24 | - $this->connection->setExpiration($periodKey.'_total', $expireInSeconds); |
|
24 | + $this->connection->setExpiration($periodKey . '_total', $expireInSeconds); |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | 29 | protected function noExpiration($periodKey) |
30 | 30 | { |
31 | - return $this->connection->timeLeft($periodKey) == -1 || ! $this->connection->exists($periodKey); |
|
31 | + return $this->connection->timeLeft($periodKey) == -1 || !$this->connection->exists($periodKey); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | protected function newExpiration($period) |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | protected function recordCountry($inc) |
13 | 13 | { |
14 | - $this->connection->increment($this->keys->visits."_countries:{$this->keys->id}", $inc, $this->getVisitorCountry()); |
|
14 | + $this->connection->increment($this->keys->visits . "_countries:{$this->keys->id}", $inc, $this->getVisitorCountry()); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | protected function recordRefer($inc) |
21 | 21 | { |
22 | - $this->connection->increment($this->keys->visits."_referers:{$this->keys->id}", $inc, $this->getVisitorReferer()); |
|
22 | + $this->connection->increment($this->keys->visits . "_referers:{$this->keys->id}", $inc, $this->getVisitorReferer()); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | protected function recordOperatingSystem($inc) |
29 | 29 | { |
30 | - $this->connection->increment($this->keys->visits."_OSes:{$this->keys->id}", $inc, $this->getVisitorOperatingSystem()); |
|
30 | + $this->connection->increment($this->keys->visits . "_OSes:{$this->keys->id}", $inc, $this->getVisitorOperatingSystem()); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | protected function recordLanguage($inc) |
37 | 37 | { |
38 | - $this->connection->increment($this->keys->visits."_languages:{$this->keys->id}", $inc, $this->getVisitorLanguage()); |
|
38 | + $this->connection->increment($this->keys->visits . "_languages:{$this->keys->id}", $inc, $this->getVisitorLanguage()); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $periodKey = $this->keys->period($period); |
48 | 48 | |
49 | 49 | $this->connection->increment($periodKey, $inc, $this->keys->id); |
50 | - $this->connection->increment($periodKey.'_total', $inc); |
|
50 | + $this->connection->increment($periodKey . '_total', $inc); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function visits() |
35 | 35 | { |
36 | - return (app()->environment('testing') ? 'testing:' : '').$this->modelName."_{$this->tag}"; |
|
36 | + return (app()->environment('testing') ? 'testing:' : '') . $this->modelName . "_{$this->tag}"; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function ip($ip) |
51 | 51 | { |
52 | - return $this->visits.'_'.Str::snake( |
|
53 | - 'recorded_ips:'.($this->instanceOfModel ? "{$this->id}:" : '') . $ip |
|
52 | + return $this->visits . '_' . Str::snake( |
|
53 | + 'recorded_ips:' . ($this->instanceOfModel ? "{$this->id}:" : '') . $ip |
|
54 | 54 | ); |
55 | 55 | } |
56 | 56 | |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function cache($limit = '*', $isLow = false) |
61 | 61 | { |
62 | - $key = $this->visits.'_lists'; |
|
62 | + $key = $this->visits . '_lists'; |
|
63 | 63 | |
64 | 64 | if ($limit == '*') { |
65 | 65 | return "{$key}:*"; |
66 | 66 | } |
67 | 67 | |
68 | - return "{$key}:".($isLow ? 'low' : 'top').$limit; |
|
68 | + return "{$key}:" . ($isLow ? 'low' : 'top') . $limit; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | if ($this->keys->id) { |
44 | 44 | $this->connection->delete($this->keys->visits, $this->keys->id); |
45 | 45 | foreach (['countries', 'referers', 'OSes', 'languages'] as $item) { |
46 | - $this->connection->delete($this->keys->visits."_{$item}:{$this->keys->id}"); |
|
46 | + $this->connection->delete($this->keys->visits . "_{$item}:{$this->keys->id}"); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | foreach ($this->periods as $period => $_) { |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | $this->ips(); |
54 | 54 | } else { |
55 | 55 | $this->connection->delete($this->keys->visits); |
56 | - $this->connection->delete($this->keys->visits.'_total'); |
|
56 | + $this->connection->delete($this->keys->visits . '_total'); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | 60 | public function allrefs() |
61 | 61 | { |
62 | - $cc = $this->connection->search($this->keys->visits.'_referers:*'); |
|
62 | + $cc = $this->connection->search($this->keys->visits . '_referers:*'); |
|
63 | 63 | |
64 | 64 | if (count($cc)) { |
65 | 65 | $this->connection->delete($cc); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | public function allOperatingSystems() |
70 | 70 | { |
71 | - $cc = $this->connection->search($this->keys->visits.'_OSes:*'); |
|
71 | + $cc = $this->connection->search($this->keys->visits . '_OSes:*'); |
|
72 | 72 | |
73 | 73 | if (count($cc)) { |
74 | 74 | $this->connection->delete($cc); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | public function allLanguages() |
79 | 79 | { |
80 | - $cc = $this->connection->search($this->keys->visits.'_languages:*'); |
|
80 | + $cc = $this->connection->search($this->keys->visits . '_languages:*'); |
|
81 | 81 | |
82 | 82 | if (count($cc)) { |
83 | 83 | $this->connection->delete($cc); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | public function allcountries() |
88 | 88 | { |
89 | - $cc = $this->connection->search($this->keys->visits.'_countries:*'); |
|
89 | + $cc = $this->connection->search($this->keys->visits . '_countries:*'); |
|
90 | 90 | |
91 | 91 | if (count($cc)) { |
92 | 92 | $this->connection->delete($cc); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | foreach ($this->periods as $period => $_) { |
102 | 102 | $periodKey = $this->keys->period($period); |
103 | 103 | $this->connection->delete($periodKey); |
104 | - $this->connection->delete($periodKey.'_total'); |
|
104 | + $this->connection->delete($periodKey . '_total'); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 |