Passed
Push — master ( a3f109...7fb3ff )
by
unknown
02:57
created
src/Traits/Record.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         //In case of using unsupported cache driver. Although 'country' is globally  
61 61
         //ignored already, we can not rely on user awareness of geoIP package restriction.
62 62
         if (
63
-            in_array(config('cache.default'),  ['file', 'dynamodb', 'database']) &&
63
+            in_array(config('cache.default'), ['file', 'dynamodb', 'database']) &&
64 64
             is_array($geoipTags = config('geoip.cache_tags')) && count($geoipTags) > 0
65 65
         ) {
66 66
             return null;
Please login to merge, or discard this patch.
src/DataEngines/EloquentEngine.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     public function get(string $key, $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
             })
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
     public function setExpiration(string $key, int $time): bool
194 194
     {
195
-         return $this->model->where(['primary_key' => $this->prefix.$key])
195
+            return $this->model->where(['primary_key' => $this->prefix.$key])
196 196
                                 ->where(function($q) {
197 197
                                     return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at');
198 198
                                 })
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
 
27 27
     public function increment(string $key, int $value, $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
 block discarded – undo
49 49
 
50 50
     public function delete($key, $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, $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,16 +82,16 @@  discard block
 block discarded – undo
82 82
 
83 83
     public function set(string $key, $value, $member = null): bool
84 84
     {
85
-        if(! empty($member) || is_numeric($member)) {
85
+        if (!empty($member) || is_numeric($member)) {
86 86
             return $this->model->updateOrCreate([
87
-                'primary_key' => $this->prefix.$key, 
87
+                'primary_key' => $this->prefix . $key, 
88 88
                 'secondary_key' => $member,
89 89
                 'score' => $value,
90 90
                 'expired_at' => null,
91 91
                 ]) instanceof Model;
92 92
         } else {
93 93
             return $this->model->updateOrCreate([
94
-                'primary_key' => $this->prefix.$key, 
94
+                'primary_key' => $this->prefix . $key, 
95 95
                 'score' => $value,
96 96
                 'expired_at' => null,
97 97
                 ]) instanceof Model;
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
     {
103 103
         $results = [];
104 104
 
105
-        if($word == '*') {
105
+        if ($word == '*') {
106 106
             $results = $this->model
107 107
                         ->where(function($q) {
108 108
                             return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at');
109 109
                         })
110 110
                         ->pluck('primary_key');
111 111
         } else {
112
-            $results = $this->model->where('primary_key', 'like', $this->prefix.str_replace('*', '%', $word))
112
+            $results = $this->model->where('primary_key', 'like', $this->prefix . str_replace('*', '%', $word))
113 113
                                 ->where(function($q) {
114 114
                                     return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at');
115 115
                                 })
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     public function flatList(string $key, int $limit = -1): array
132 132
     {
133 133
         return array_slice(
134
-            $this->model->where(['primary_key' => $this->prefix.$key, 'secondary_key' => null])
134
+            $this->model->where(['primary_key' => $this->prefix . $key, 'secondary_key' => null])
135 135
                         ->where(function($q) {
136 136
                             return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at');
137 137
                         })
@@ -141,29 +141,29 @@  discard block
 block discarded – undo
141 141
 
142 142
     public function addToFlatList(string $key, $value): bool
143 143
     {
144
-        $row = $this->model->firstOrNew(['primary_key' => $this->prefix.$key, 'secondary_key' => null]);
144
+        $row = $this->model->firstOrNew(['primary_key' => $this->prefix . $key, 'secondary_key' => null]);
145 145
 
146
-        if($row->expired_at !== null && \Carbon\Carbon::now()->gt($row->expired_at)) {
146
+        if ($row->expired_at !== null && \Carbon\Carbon::now()->gt($row->expired_at)) {
147 147
             $row->list = (array) $value;
148 148
             $row->expired_at = null;
149 149
         } else {
150 150
             $row->list = array_merge($row->list ?? [], (array) $value);
151 151
         }
152 152
 
153
-        $row->score =  $row->score ?? 0;
153
+        $row->score = $row->score ?? 0;
154 154
         return (bool) $row->save();
155 155
     }
156 156
 
157 157
     public function valueList(string $key, int $limit = -1, bool $orderByAsc = false, bool $withValues = false): array
158 158
     {
159
-        $rows = $this->model->where('primary_key', $this->prefix.$key)
159
+        $rows = $this->model->where('primary_key', $this->prefix . $key)
160 160
                             ->where(function($q) {
161 161
                                 return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at');
162 162
                             })
163 163
                             ->whereNotNull('secondary_key')
164 164
                             ->orderBy('score', $orderByAsc ? 'asc' : 'desc')
165 165
                             ->when($limit > -1, function($q) use($limit) {
166
-                                return $q->limit($limit+1);
166
+                                return $q->limit($limit + 1);
167 167
                             })->pluck('score', 'secondary_key') ?? \Illuminate\Support\Collection::make();
168 168
 
169 169
         return $withValues ? $rows->toArray() : array_keys($rows->toArray());
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
     public function exists(string $key): bool
173 173
     {
174
-        return $this->model->where(['primary_key' => $this->prefix.$key, 'secondary_key' => null])
174
+        return $this->model->where(['primary_key' => $this->prefix . $key, 'secondary_key' => null])
175 175
                             ->where(function($q) {
176 176
                                 return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at');
177 177
                             })
@@ -180,19 +180,19 @@  discard block
 block discarded – undo
180 180
 
181 181
     public function timeLeft(string $key): int
182 182
     {
183
-        $expired_at = $this->model->where(['primary_key' => $this->prefix.$key])->value('expired_at');
183
+        $expired_at = $this->model->where(['primary_key' => $this->prefix . $key])->value('expired_at');
184 184
 
185
-        if($expired_at === null) {
185
+        if ($expired_at === null) {
186 186
             return -2;
187 187
         }
188 188
 
189
-        $ttl =  $expired_at->timestamp - \Carbon\Carbon::now()->timestamp;
189
+        $ttl = $expired_at->timestamp - \Carbon\Carbon::now()->timestamp;
190 190
         return $ttl <= 0 ? -1 : $ttl;
191 191
     }
192 192
 
193 193
     public function setExpiration(string $key, int $time): bool
194 194
     {
195
-         return $this->model->where(['primary_key' => $this->prefix.$key])
195
+         return $this->model->where(['primary_key' => $this->prefix . $key])
196 196
                                 ->where(function($q) {
197 197
                                     return $q->where('expired_at', '>', \Carbon\Carbon::now())->orWhereNull('expired_at');
198 198
                                 })
Please login to merge, or discard this patch.