|
1
|
|
|
<?php |
|
2
|
|
|
namespace UserAgentParser\Model; |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* User agent model |
|
6
|
|
|
* |
|
7
|
|
|
* @author Martin Keckeis <[email protected]> |
|
8
|
|
|
* @license MIT |
|
9
|
|
|
*/ |
|
10
|
|
|
class UserAgent |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* Provider name |
|
14
|
|
|
* |
|
15
|
|
|
* @var string |
|
16
|
|
|
*/ |
|
17
|
|
|
private $providerName; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Provider version |
|
21
|
|
|
* |
|
22
|
|
|
* @var string |
|
23
|
|
|
*/ |
|
24
|
|
|
private $providerVersion; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var Browser |
|
28
|
|
|
*/ |
|
29
|
|
|
private $browser; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var RenderingEngine |
|
33
|
|
|
*/ |
|
34
|
|
|
private $renderingEngine; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var OperatingSystem |
|
38
|
|
|
*/ |
|
39
|
|
|
private $operatingSystem; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var Device |
|
43
|
|
|
*/ |
|
44
|
|
|
private $device; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var Bot |
|
48
|
|
|
*/ |
|
49
|
|
|
private $bot; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var mixed |
|
53
|
|
|
*/ |
|
54
|
|
|
private $providerResultRaw; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* |
|
58
|
|
|
* @param string $provider |
|
|
|
|
|
|
59
|
|
|
*/ |
|
60
|
9 |
|
public function __construct($providerName = null, $providerVersion = null) |
|
61
|
|
|
{ |
|
62
|
9 |
|
$this->providerName = $providerName; |
|
63
|
9 |
|
$this->providerVersion = $providerVersion; |
|
64
|
|
|
|
|
65
|
9 |
|
$this->browser = new Browser(); |
|
66
|
9 |
|
$this->renderingEngine = new RenderingEngine(); |
|
67
|
9 |
|
$this->operatingSystem = new OperatingSystem(); |
|
68
|
9 |
|
$this->device = new Device(); |
|
69
|
9 |
|
$this->bot = new Bot(); |
|
70
|
9 |
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* |
|
74
|
|
|
* @return string |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getProviderName() |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->providerName; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* |
|
83
|
|
|
* @return string |
|
84
|
|
|
*/ |
|
85
|
|
|
public function getProviderVersion() |
|
86
|
|
|
{ |
|
87
|
|
|
return $this->providerVersion; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @param Browser $browser |
|
92
|
|
|
*/ |
|
93
|
1 |
|
public function setBrowser(Browser $browser) |
|
94
|
|
|
{ |
|
95
|
1 |
|
$this->browser = $browser; |
|
96
|
1 |
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @return Browser |
|
100
|
|
|
*/ |
|
101
|
2 |
|
public function getBrowser() |
|
102
|
|
|
{ |
|
103
|
2 |
|
return $this->browser; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @param RenderingEngine $renderingEngine |
|
108
|
|
|
*/ |
|
109
|
1 |
|
public function setRenderingEngine(RenderingEngine $renderingEngine) |
|
110
|
|
|
{ |
|
111
|
1 |
|
$this->renderingEngine = $renderingEngine; |
|
112
|
1 |
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @return RenderingEngine |
|
116
|
|
|
*/ |
|
117
|
2 |
|
public function getRenderingEngine() |
|
118
|
|
|
{ |
|
119
|
2 |
|
return $this->renderingEngine; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @param OperatingSystem $operatingSystem |
|
124
|
|
|
*/ |
|
125
|
1 |
|
public function setOperatingSystem(OperatingSystem $operatingSystem) |
|
126
|
|
|
{ |
|
127
|
1 |
|
$this->operatingSystem = $operatingSystem; |
|
128
|
1 |
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @return OperatingSystem |
|
132
|
|
|
*/ |
|
133
|
2 |
|
public function getOperatingSystem() |
|
134
|
|
|
{ |
|
135
|
2 |
|
return $this->operatingSystem; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @param Device $device |
|
140
|
|
|
*/ |
|
141
|
1 |
|
public function setDevice(Device $device) |
|
142
|
|
|
{ |
|
143
|
1 |
|
$this->device = $device; |
|
144
|
1 |
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* @return Device |
|
148
|
|
|
*/ |
|
149
|
3 |
|
public function getDevice() |
|
150
|
|
|
{ |
|
151
|
3 |
|
return $this->device; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* @param Bot $bot |
|
156
|
|
|
*/ |
|
157
|
1 |
|
public function setBot(Bot $bot) |
|
158
|
|
|
{ |
|
159
|
1 |
|
$this->bot = $bot; |
|
160
|
1 |
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* @return Bot |
|
164
|
|
|
*/ |
|
165
|
3 |
|
public function getBot() |
|
166
|
|
|
{ |
|
167
|
3 |
|
return $this->bot; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* |
|
172
|
|
|
* @return boolean |
|
173
|
|
|
*/ |
|
174
|
1 |
|
public function isBot() |
|
175
|
|
|
{ |
|
176
|
1 |
|
if ($this->getBot()->getIsBot() === true) { |
|
177
|
1 |
|
return true; |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
1 |
|
return false; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* |
|
185
|
|
|
* @return boolean |
|
186
|
|
|
*/ |
|
187
|
1 |
|
public function isMobile() |
|
188
|
|
|
{ |
|
189
|
1 |
|
if ($this->getDevice()->getIsMobile() === true) { |
|
190
|
1 |
|
return true; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
1 |
|
return false; |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
/** |
|
197
|
|
|
* @param mixed $providerResultRaw |
|
198
|
|
|
*/ |
|
199
|
1 |
|
public function setProviderResultRaw($providerResultRaw) |
|
200
|
|
|
{ |
|
201
|
1 |
|
$this->providerResultRaw = $providerResultRaw; |
|
202
|
1 |
|
} |
|
203
|
|
|
|
|
204
|
|
|
/** |
|
205
|
|
|
* @return mixed |
|
206
|
|
|
*/ |
|
207
|
2 |
|
public function getProviderResultRaw() |
|
208
|
|
|
{ |
|
209
|
2 |
|
return $this->providerResultRaw; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* @return array |
|
214
|
|
|
*/ |
|
215
|
1 |
|
public function toArray($includeResultRaw = false) |
|
216
|
|
|
{ |
|
217
|
|
|
$data = [ |
|
218
|
1 |
|
'browser' => $this->getBrowser()->toArray(), |
|
219
|
1 |
|
'renderingEngine' => $this->getRenderingEngine()->toArray(), |
|
220
|
1 |
|
'operatingSystem' => $this->getOperatingSystem()->toArray(), |
|
221
|
1 |
|
'device' => $this->getDevice()->toArray(), |
|
222
|
1 |
|
'bot' => $this->getBot()->toArray(), |
|
223
|
|
|
]; |
|
224
|
|
|
|
|
225
|
|
|
// should be only used for debug |
|
226
|
1 |
|
if ($includeResultRaw === true) { |
|
227
|
1 |
|
$data['providerResultRaw'] = $this->getProviderResultRaw(); |
|
228
|
|
|
} |
|
229
|
|
|
|
|
230
|
1 |
|
return $data; |
|
231
|
|
|
} |
|
232
|
|
|
} |
|
233
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$irelandis not defined by the methodfinale(...).The most likely cause is that the parameter was changed, but the annotation was not.