1 | <?php |
||
31 | class Client extends Fluent |
||
32 | { |
||
33 | use FluentArrayAccess; |
||
34 | |||
35 | /** |
||
36 | * The Agent instance. |
||
37 | * |
||
38 | * @var \Jenssegers\Agent\Agent |
||
39 | */ |
||
40 | protected $agent; |
||
41 | |||
42 | /** |
||
43 | * Create a new Client instance. |
||
44 | * |
||
45 | * @param array|object $attributes |
||
46 | */ |
||
47 | public function __construct($attributes = []) |
||
53 | |||
54 | /** |
||
55 | * Merge new data into the current attributes. |
||
56 | * |
||
57 | * @param array ...$data |
||
58 | * @return $this |
||
59 | */ |
||
60 | public function add(array ...$data) |
||
66 | |||
67 | /** |
||
68 | * Check the version of the given property in the User-Agent. |
||
69 | * |
||
70 | * @param string $propertyName |
||
71 | * @return string|float|false |
||
72 | * |
||
73 | * @see \Jenssegers\Agent\Agent::version() |
||
74 | */ |
||
75 | public function version($propertyName, $type = Agent::VERSION_TYPE_STRING) |
||
81 | |||
82 | /** |
||
83 | * Get the Agent instance. |
||
84 | * |
||
85 | * @return \Jenssegers\Agent\Agent |
||
86 | */ |
||
87 | public function agent() |
||
91 | |||
92 | /** |
||
93 | * Set the Agent instance. |
||
94 | * |
||
95 | * @param \Jenssegers\Agent\Agent $agent |
||
96 | * @return $this |
||
97 | */ |
||
98 | public function setAgent(Agent $agent) |
||
104 | |||
105 | /** |
||
106 | * Set the User-Agent to be used. |
||
107 | * |
||
108 | * @param string $userAgent |
||
109 | * @return $this |
||
110 | */ |
||
111 | public function setUserAgent($userAgent = null) |
||
117 | |||
118 | /** |
||
119 | * Parse Agent information. |
||
120 | * |
||
121 | * @return $this |
||
122 | */ |
||
123 | public function parseAgent() |
||
130 | |||
131 | /** |
||
132 | * Parse common client. |
||
133 | * |
||
134 | * @return array |
||
135 | */ |
||
136 | protected function parseCommonClient() |
||
160 | |||
161 | /** |
||
162 | * Parse API client from the User-Agent. |
||
163 | * |
||
164 | * @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)` |
||
165 | * |
||
166 | * @return array |
||
167 | */ |
||
168 | protected function parseApiClient() |
||
174 | |||
175 | /** |
||
176 | * Get API client information from the User-Agent. |
||
177 | * |
||
178 | * @param string $userAgent |
||
179 | * @return array |
||
180 | */ |
||
181 | protected function getApiClientInfo($userAgent) |
||
193 | |||
194 | /** |
||
195 | * Get API client attributes. |
||
196 | * |
||
197 | * @param array $info |
||
198 | * @return array |
||
199 | */ |
||
200 | protected function getApiClientAttributes($info) |
||
243 | |||
244 | /** |
||
245 | * Reset API client attributes. |
||
246 | */ |
||
247 | protected function resetApiClientAttributes() |
||
262 | |||
263 | /** |
||
264 | * Handle dynamic calls to the Agent instance. |
||
265 | * |
||
266 | * @param string $method |
||
267 | * @param array $parameters |
||
268 | * @return mixed |
||
269 | */ |
||
270 | public function __call($method, $parameters) |
||
274 | } |
||
275 |