@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace ElfSundae\Laravel\Support\Services\Agent; |
4 | 4 | |
5 | -use Illuminate\Support\Arr; |
|
6 | 5 | use Jenssegers\Agent\Agent; |
7 | 6 | use Illuminate\Support\Fluent; |
8 | 7 | use ElfSundae\Laravel\Support\Traits\FluentArrayAccess; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | { |
81 | 81 | $version = $this->agent->version($propertyName, $type); |
82 | 82 | |
83 | - return is_string($version) ? str_replace(['_', '+'], '.', $version) : $version; |
|
83 | + return is_string($version) ? str_replace([ '_', '+' ], '.', $version) : $version; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | if (func_num_args() > 0) { |
107 | 107 | $checkChannels = is_array(func_get_arg(0)) ? func_get_arg(0) : func_get_args(); |
108 | 108 | |
109 | - return in_arrayi($this->attributes['appChannel'], $checkChannels); |
|
109 | + return in_arrayi($this->attributes[ 'appChannel' ], $checkChannels); |
|
110 | 110 | } |
111 | 111 | |
112 | - return $this->attributes['appChannel']; |
|
112 | + return $this->attributes[ 'appChannel' ]; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -153,15 +153,15 @@ discard block |
||
153 | 153 | ]; |
154 | 154 | |
155 | 155 | if ($this->agent->is('iOS')) { |
156 | - $info['os'] = 'iOS'; |
|
156 | + $info[ 'os' ] = 'iOS'; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | if ($this->agent->is('AndroidOS')) { |
160 | - $info['os'] = 'Android'; |
|
160 | + $info[ 'os' ] = 'Android'; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | if (is_string($this->version('MicroMessenger'))) { |
164 | - $info['isWechat'] = true; |
|
164 | + $info[ 'isWechat' ] = true; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | return array_filter($info); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $this->getAppClientData($this->agent->getUserAgent()) |
181 | 181 | ); |
182 | 182 | |
183 | - if (! $data) { |
|
183 | + if (!$data) { |
|
184 | 184 | $this->resetAppClientAttributes(); |
185 | 185 | } |
186 | 186 | |
@@ -196,14 +196,14 @@ discard block |
||
196 | 196 | protected function getAppClientData($userAgent) |
197 | 197 | { |
198 | 198 | if (preg_match('#client\((.+)\)#is', $userAgent, $matches)) { |
199 | - if ($info = json_decode(urlsafe_base64_decode($matches[1]), true)) { |
|
200 | - if (is_array($info) && ! empty($info)) { |
|
199 | + if ($info = json_decode(urlsafe_base64_decode($matches[ 1 ]), true)) { |
|
200 | + if (is_array($info) && !empty($info)) { |
|
201 | 201 | return $info; |
202 | 202 | } |
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | - return []; |
|
206 | + return [ ]; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -215,29 +215,29 @@ discard block |
||
215 | 215 | protected function getAppClientAttributes($info) |
216 | 216 | { |
217 | 217 | $info = array_filter($info); |
218 | - $data = []; |
|
218 | + $data = [ ]; |
|
219 | 219 | |
220 | 220 | if ( |
221 | - ($data['os'] = array_get($info, 'os')) && |
|
222 | - ($data['osVersion'] = array_get($info, 'osV')) && |
|
223 | - ($data['platform'] = array_get($info, 'pf')) && |
|
224 | - ($data['locale'] = array_get($info, 'loc')) && |
|
225 | - ($data['app'] = array_get($info, 'app')) && |
|
226 | - ($data['appVersion'] = array_get($info, 'appV')) && |
|
227 | - ($data['appChannel'] = array_get($info, 'appC')) && |
|
228 | - ($data['network'] = array_get($info, 'net')) && |
|
229 | - ($data['udid'] = array_get($info, 'udid')) |
|
221 | + ($data[ 'os' ] = array_get($info, 'os')) && |
|
222 | + ($data[ 'osVersion' ] = array_get($info, 'osV')) && |
|
223 | + ($data[ 'platform' ] = array_get($info, 'pf')) && |
|
224 | + ($data[ 'locale' ] = array_get($info, 'loc')) && |
|
225 | + ($data[ 'app' ] = array_get($info, 'app')) && |
|
226 | + ($data[ 'appVersion' ] = array_get($info, 'appV')) && |
|
227 | + ($data[ 'appChannel' ] = array_get($info, 'appC')) && |
|
228 | + ($data[ 'network' ] = array_get($info, 'net')) && |
|
229 | + ($data[ 'udid' ] = array_get($info, 'udid')) |
|
230 | 230 | ) { |
231 | - if ($data['os'] === 'iPhone OS') { |
|
232 | - $data['os'] = 'iOS'; |
|
231 | + if ($data[ 'os' ] === 'iPhone OS') { |
|
232 | + $data[ 'os' ] = 'iOS'; |
|
233 | 233 | } |
234 | 234 | |
235 | - $data['isAppClient'] = true; |
|
235 | + $data[ 'isAppClient' ] = true; |
|
236 | 236 | |
237 | 237 | return array_filter($data); |
238 | 238 | } |
239 | 239 | |
240 | - return []; |
|
240 | + return [ ]; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -246,12 +246,12 @@ discard block |
||
246 | 246 | protected function resetAppClientAttributes() |
247 | 247 | { |
248 | 248 | unset( |
249 | - $this->attributes['app'], |
|
250 | - $this->attributes['appVersion'], |
|
251 | - $this->attributes['appChannel'], |
|
252 | - $this->attributes['network'], |
|
253 | - $this->attributes['udid'], |
|
254 | - $this->attributes['isAppClient'] |
|
249 | + $this->attributes[ 'app' ], |
|
250 | + $this->attributes[ 'appVersion' ], |
|
251 | + $this->attributes[ 'appChannel' ], |
|
252 | + $this->attributes[ 'network' ], |
|
253 | + $this->attributes[ 'udid' ], |
|
254 | + $this->attributes[ 'isAppClient' ] |
|
255 | 255 | ); |
256 | 256 | } |
257 | 257 | |
@@ -264,6 +264,6 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public function __call($method, $parameters) |
266 | 266 | { |
267 | - return call_user_func_array([$this->agent, $method], $parameters); |
|
267 | + return call_user_func_array([ $this->agent, $method ], $parameters); |
|
268 | 268 | } |
269 | 269 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | use Ramsey\Uuid\Uuid; |
4 | 4 | |
5 | -if (! function_exists('is_domain')) { |
|
5 | +if (!function_exists('is_domain')) { |
|
6 | 6 | /** |
7 | 7 | * Determines the current domain equals to the given domain identifier. |
8 | 8 | * |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | } |
16 | 16 | } |
17 | 17 | |
18 | -if (! function_exists('app_url')) { |
|
18 | +if (!function_exists('app_url')) { |
|
19 | 19 | /** |
20 | 20 | * Generate an URL for the application. |
21 | 21 | * |
@@ -27,14 +27,14 @@ discard block |
||
27 | 27 | function app_url($path = '', $parameters = null, $identifier = 'site') |
28 | 28 | { |
29 | 29 | $path = trim($path, '/'); |
30 | - if (! empty($path) && ! starts_with($path, ['?', '&', '#'])) { |
|
30 | + if (!empty($path) && !starts_with($path, [ '?', '&', '#' ])) { |
|
31 | 31 | $path = '/'.$path; |
32 | 32 | } |
33 | 33 | |
34 | - if (! is_null($parameters)) { |
|
34 | + if (!is_null($parameters)) { |
|
35 | 35 | $query = http_build_query($parameters); |
36 | - if (! empty($query)) { |
|
37 | - $path .= (str_contains($path, ['?', '&', '#']) ? '&' : '?').$query; |
|
36 | + if (!empty($query)) { |
|
37 | + $path .= (str_contains($path, [ '?', '&', '#' ]) ? '&' : '?').$query; |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | -if (! function_exists('revision')) { |
|
49 | +if (!function_exists('revision')) { |
|
50 | 50 | /** |
51 | 51 | * Get the revisioned asset path. |
52 | 52 | * |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | -if (! function_exists('asset_from')) { |
|
66 | +if (!function_exists('asset_from')) { |
|
67 | 67 | /** |
68 | 68 | * Generate the URL to an asset from a custom root domain such as CDN, etc. |
69 | 69 | * |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | -if (! function_exists('asset_url')) { |
|
81 | +if (!function_exists('asset_url')) { |
|
82 | 82 | /** |
83 | 83 | * Generate an asset URL. |
84 | 84 | * |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | -if (! function_exists('cdn_url')) { |
|
98 | +if (!function_exists('cdn_url')) { |
|
99 | 99 | /** |
100 | 100 | * Generate an asset CDN URL. |
101 | 101 | * |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
111 | -if (! function_exists('gravatar')) { |
|
111 | +if (!function_exists('gravatar')) { |
|
112 | 112 | /** |
113 | 113 | * Generate a Gravatar url. |
114 | 114 | * |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | -if (! function_exists('optimus_encode')) { |
|
141 | +if (!function_exists('optimus_encode')) { |
|
142 | 142 | /** |
143 | 143 | * Encode a number with Optimus. |
144 | 144 | * |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | -if (! function_exists('optimus_decode')) { |
|
154 | +if (!function_exists('optimus_decode')) { |
|
155 | 155 | /** |
156 | 156 | * Decode a number with Optimus. |
157 | 157 | * |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | -if (! function_exists('random_uuid')) { |
|
167 | +if (!function_exists('random_uuid')) { |
|
168 | 168 | /** |
169 | 169 | * Generate a version 4 (random) UUID. |
170 | 170 | * |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | public function boot() |
16 | 16 | { |
17 | - $this->app['view']->share('client', $this->app['client']); |
|
17 | + $this->app[ 'view' ]->share('client', $this->app[ 'client' ]); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | */ |
37 | 37 | protected function registerAgent() |
38 | 38 | { |
39 | - if (! $this->app->bound('agent')) { |
|
40 | - $this->app->singleton('agent', function () { |
|
39 | + if (!$this->app->bound('agent')) { |
|
40 | + $this->app->singleton('agent', function() { |
|
41 | 41 | return new Agent; |
42 | 42 | }); |
43 | 43 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | protected function registerClient() |
54 | 54 | { |
55 | - $this->app->singleton('client', function ($app) { |
|
55 | + $this->app->singleton('client', function($app) { |
|
56 | 56 | return (new Client)->setAgent($app->make('agent')); |
57 | 57 | }); |
58 | 58 |