1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Serhii Nekhaienko <[email protected]> |
4
|
|
|
* @license GPL |
5
|
|
|
* @copyright Serhii Nekhaienko © 2018 |
6
|
|
|
* @version 4.0.0 |
7
|
|
|
* @project endorphin-studio/browser-detector |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace EndorphinStudio\Detector\Data; |
11
|
|
|
|
12
|
|
|
use EndorphinStudio\Detector\Detector; |
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class Result |
16
|
|
|
* Class with result of detection |
17
|
|
|
* @package EndorphinStudio\Detector\Data |
18
|
|
|
*/ |
19
|
|
|
class Result implements \JsonSerializable |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var Detector |
23
|
|
|
*/ |
24
|
|
|
private $detector; |
25
|
|
|
private $version = '1.0.8'; |
26
|
|
|
|
27
|
|
|
public function getCoreVersion(): string |
28
|
|
|
{ |
29
|
|
|
if(!is_null($this->detector) && method_exists($this->detector, 'getVersion')) { |
30
|
|
|
return $this->detector->getVersion(); |
31
|
|
|
} |
32
|
|
|
return '4.0.4'; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function getModulesVersions(): array |
36
|
|
|
{ |
37
|
|
|
return [ |
38
|
|
|
'endorphin-studio/browser-detector-data' => $this->version |
39
|
|
|
]; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function getDetectorVersion(): string |
43
|
|
|
{ |
44
|
|
|
return 'method'.__METHOD__.' is deprecated; soon it will be removed'; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function getDataVersion(): string |
48
|
|
|
{ |
49
|
|
|
return 'method'.__METHOD__.' is deprecated; soon it will be removed'; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Get User Agent |
54
|
|
|
* @return string |
55
|
|
|
*/ |
56
|
|
|
public function getUserAgent(): string |
57
|
|
|
{ |
58
|
|
|
return $this->userAgent; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** @var string UserAgent */ |
62
|
|
|
protected $userAgent = null; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @var Os Result of os detection |
66
|
|
|
*/ |
67
|
|
|
protected $os; |
68
|
|
|
/** |
69
|
|
|
* @var Browser Result of browser detection |
70
|
|
|
*/ |
71
|
|
|
protected $browser; |
72
|
|
|
/** |
73
|
|
|
* @var Device Result of device detection |
74
|
|
|
*/ |
75
|
|
|
protected $device; |
76
|
|
|
/** |
77
|
|
|
* @var Robot Result of robot detection |
78
|
|
|
*/ |
79
|
|
|
protected $robot; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @var boolean true if user is robot |
83
|
|
|
*/ |
84
|
|
|
protected $isRobot = false; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @var boolean true if device is touch |
88
|
|
|
*/ |
89
|
|
|
protected $isTouch = false; |
90
|
|
|
/** |
91
|
|
|
* @var boolean true if device is mobile |
92
|
|
|
*/ |
93
|
|
|
protected $isMobile = false; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* True if user is robot |
97
|
|
|
* @return bool |
98
|
|
|
*/ |
99
|
|
|
public function isRobot(): bool |
100
|
|
|
{ |
101
|
|
|
return $this->isRobot; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Setter |
106
|
|
|
* @param bool $isRobot |
107
|
|
|
*/ |
108
|
|
|
public function setIsRobot(bool $isRobot) |
109
|
|
|
{ |
110
|
|
|
$this->isRobot = $isRobot; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* True if user is touch |
115
|
|
|
* @return bool |
116
|
|
|
*/ |
117
|
|
|
public function isTouch(): bool |
118
|
|
|
{ |
119
|
|
|
return $this->isTouch; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Setter |
124
|
|
|
* @param bool $isTouch |
125
|
|
|
*/ |
126
|
|
|
public function setIsTouch(bool $isTouch) |
127
|
|
|
{ |
128
|
|
|
$this->isTouch = $isTouch; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* True if user is mobile |
133
|
|
|
* @return bool |
134
|
|
|
*/ |
135
|
|
|
public function isMobile(): bool |
136
|
|
|
{ |
137
|
|
|
return $this->isMobile; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Setter |
142
|
|
|
* @param bool $isMobile |
143
|
|
|
*/ |
144
|
|
|
public function setIsMobile(bool $isMobile) |
145
|
|
|
{ |
146
|
|
|
$this->isMobile = $isMobile; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* True if user is tablet |
151
|
|
|
* @return bool |
152
|
|
|
*/ |
153
|
|
|
public function isTablet(): bool |
154
|
|
|
{ |
155
|
|
|
return $this->isTablet; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Setter |
160
|
|
|
* @param bool $isTablet |
161
|
|
|
*/ |
162
|
|
|
public function setIsTablet(bool $isTablet) |
163
|
|
|
{ |
164
|
|
|
$this->isTablet = $isTablet; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** @var boolean true if user is tablet */ |
168
|
|
|
protected $isTablet = false; |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Result constructor. |
172
|
|
|
* @param string $userAgent User Agent |
173
|
|
|
*/ |
174
|
|
|
public function __construct(string $userAgent, Detector $detector = null) |
175
|
|
|
{ |
176
|
|
|
$this->os = new Os($this); |
177
|
|
|
$this->device = new Device($this); |
178
|
|
|
$this->browser = new Browser($this); |
179
|
|
|
$this->robot = new Robot($this); |
180
|
|
|
$this->userAgent = $userAgent; |
181
|
|
|
$this->detector = $detector; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* Get result of os detection |
186
|
|
|
* @return Os |
187
|
|
|
*/ |
188
|
|
|
public function getOs(): Os |
189
|
|
|
{ |
190
|
|
|
return $this->os; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Get result of browser detection |
195
|
|
|
* @return Browser |
196
|
|
|
*/ |
197
|
|
|
public function getBrowser(): Browser |
198
|
|
|
{ |
199
|
|
|
return $this->browser; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* Get result of device detection |
204
|
|
|
* @return Device |
205
|
|
|
*/ |
206
|
|
|
public function getDevice(): Device |
207
|
|
|
{ |
208
|
|
|
return $this->device; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* Get result of robot detection |
213
|
|
|
* @return Robot |
214
|
|
|
*/ |
215
|
|
|
public function getRobot(): Robot |
216
|
|
|
{ |
217
|
|
|
return $this->robot; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
public function jsonSerialize() |
221
|
|
|
{ |
222
|
|
|
return get_object_vars($this); |
223
|
|
|
} |
224
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths