1 | <?php |
||
24 | class Client extends Fluent |
||
25 | { |
||
26 | use FluentArrayAccess; |
||
27 | |||
28 | /** |
||
29 | * The Agent instance. |
||
30 | * |
||
31 | * @var \Jenssegers\Agent\Agent |
||
32 | */ |
||
33 | protected $agent; |
||
34 | |||
35 | /** |
||
36 | * Get the Agent instance. |
||
37 | * |
||
38 | * @return \Jenssegers\Agent\Agent |
||
39 | */ |
||
40 | public function agent() |
||
44 | |||
45 | /** |
||
46 | * Set the Agent instance. |
||
47 | * |
||
48 | * @param \Jenssegers\Agent\Agent $agent |
||
49 | * @return $this |
||
50 | */ |
||
51 | public function setAgent(Agent $agent) |
||
57 | |||
58 | /** |
||
59 | * Merge new data into the current attributes. |
||
60 | * |
||
61 | * @param array ...$data |
||
62 | * @return $this |
||
63 | */ |
||
64 | public function add(array ...$data) |
||
70 | |||
71 | /** |
||
72 | * Check the version of the given property in the User-Agent. |
||
73 | * |
||
74 | * @param string $propertyName |
||
75 | * @return string|float|false |
||
76 | * |
||
77 | * @see \Jenssegers\Agent\Agent::version() |
||
78 | */ |
||
79 | public function version($propertyName, $type = Agent::VERSION_TYPE_STRING) |
||
85 | |||
86 | /** |
||
87 | * Check a certain value exists, case insensitived. |
||
88 | * |
||
89 | * @param string $value |
||
90 | * @return bool |
||
91 | */ |
||
92 | public function is($value) |
||
98 | |||
99 | /** |
||
100 | * Get or check the current app channel. |
||
101 | * |
||
102 | * @return string|bool |
||
103 | */ |
||
104 | public function appChannel() |
||
114 | |||
115 | /** |
||
116 | * Set the User-Agent to be used. |
||
117 | * |
||
118 | * @param string $userAgent |
||
119 | * @return $this |
||
120 | */ |
||
121 | public function setUserAgent($userAgent = null) |
||
127 | |||
128 | /** |
||
129 | * Parse Agent information. |
||
130 | * |
||
131 | * @return $this |
||
132 | */ |
||
133 | protected function parseAgent() |
||
140 | |||
141 | /** |
||
142 | * Parse common client. |
||
143 | * |
||
144 | * @return array |
||
145 | */ |
||
146 | protected function parseCommonClient() |
||
169 | |||
170 | /** |
||
171 | * Parse app client from the User-Agent. |
||
172 | * |
||
173 | * @example `Mozilla/5.0 (iPhone; CPU iPhone OS 8_4 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12H143 _ua(eyJuZXQiOiJXaUZpIiwib3MiOiJpT1MiLCJhcHBWIjoiMC4xLjIiLCJvc1YiOiI4LjQiLCJhcHAiOiJndXBpYW8iLCJhcHBDIjoiRGVidWciLCJ0ZGlkIjoiaDNiYjFmNTBhYzBhMzdkYmE4ODhlMTgyNjU3OWJkZmZmIiwiYWNpZCI6IjIxZDNmYmQzNDNmMjViYmI0MzU2ZGEyMmJmZjUxZDczZjg0YWQwNmQiLCJsb2MiOiJ6aF9DTiIsInBmIjoiaVBob25lNywxIn0)` |
||
174 | * |
||
175 | * @return array |
||
176 | */ |
||
177 | protected function parseAppClient() |
||
189 | |||
190 | /** |
||
191 | * Get app client information from the User-Agent. |
||
192 | * |
||
193 | * @param string $userAgent |
||
194 | * @return array |
||
195 | */ |
||
196 | protected function getAppClientData($userAgent) |
||
208 | |||
209 | /** |
||
210 | * Get app client attributes. |
||
211 | * |
||
212 | * @param array $info |
||
213 | * @return array |
||
214 | */ |
||
215 | protected function getAppClientAttributes($info) |
||
242 | |||
243 | /** |
||
244 | * Reset app client attributes. |
||
245 | */ |
||
246 | protected function resetAppClientAttributes() |
||
257 | |||
258 | /** |
||
259 | * Handle dynamic calls to the Agent instance. |
||
260 | * |
||
261 | * @param string $method |
||
262 | * @param array $parameters |
||
263 | * @return mixed |
||
264 | */ |
||
265 | public function __call($method, $parameters) |
||
269 | } |
||
270 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.