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.7'; |
26
|
|
|
|
27
|
|
|
public function getDetectorVersion(): 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 getDataVersion(): string |
36
|
|
|
{ |
37
|
|
|
return $this->version; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Get User Agent |
42
|
|
|
* @return string |
43
|
|
|
*/ |
44
|
|
|
public function getUserAgent(): string |
45
|
|
|
{ |
46
|
|
|
return $this->userAgent; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** @var string UserAgent */ |
50
|
|
|
protected $userAgent = null; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var Os Result of os detection |
54
|
|
|
*/ |
55
|
|
|
protected $os; |
56
|
|
|
/** |
57
|
|
|
* @var Browser Result of browser detection |
58
|
|
|
*/ |
59
|
|
|
protected $browser; |
60
|
|
|
/** |
61
|
|
|
* @var Device Result of device detection |
62
|
|
|
*/ |
63
|
|
|
protected $device; |
64
|
|
|
/** |
65
|
|
|
* @var Robot Result of robot detection |
66
|
|
|
*/ |
67
|
|
|
protected $robot; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @var boolean true if user is robot |
71
|
|
|
*/ |
72
|
|
|
protected $isRobot = false; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @var boolean true if device is touch |
76
|
|
|
*/ |
77
|
|
|
protected $isTouch = false; |
78
|
|
|
/** |
79
|
|
|
* @var boolean true if device is mobile |
80
|
|
|
*/ |
81
|
|
|
protected $isMobile = false; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* True if user is robot |
85
|
|
|
* @return bool |
86
|
|
|
*/ |
87
|
|
|
public function isRobot(): bool |
88
|
|
|
{ |
89
|
|
|
return $this->isRobot; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Setter |
94
|
|
|
* @param bool $isRobot |
95
|
|
|
*/ |
96
|
|
|
public function setIsRobot(bool $isRobot) |
97
|
|
|
{ |
98
|
|
|
$this->isRobot = $isRobot; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* True if user is touch |
103
|
|
|
* @return bool |
104
|
|
|
*/ |
105
|
|
|
public function isTouch(): bool |
106
|
|
|
{ |
107
|
|
|
return $this->isTouch; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Setter |
112
|
|
|
* @param bool $isTouch |
113
|
|
|
*/ |
114
|
|
|
public function setIsTouch(bool $isTouch) |
115
|
|
|
{ |
116
|
|
|
$this->isTouch = $isTouch; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* True if user is mobile |
121
|
|
|
* @return bool |
122
|
|
|
*/ |
123
|
|
|
public function isMobile(): bool |
124
|
|
|
{ |
125
|
|
|
return $this->isMobile; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Setter |
130
|
|
|
* @param bool $isMobile |
131
|
|
|
*/ |
132
|
|
|
public function setIsMobile(bool $isMobile) |
133
|
|
|
{ |
134
|
|
|
$this->isMobile = $isMobile; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* True if user is tablet |
139
|
|
|
* @return bool |
140
|
|
|
*/ |
141
|
|
|
public function isTablet(): bool |
142
|
|
|
{ |
143
|
|
|
return $this->isTablet; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Setter |
148
|
|
|
* @param bool $isTablet |
149
|
|
|
*/ |
150
|
|
|
public function setIsTablet(bool $isTablet) |
151
|
|
|
{ |
152
|
|
|
$this->isTablet = $isTablet; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** @var boolean true if user is tablet */ |
156
|
|
|
protected $isTablet = false; |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Result constructor. |
160
|
|
|
* @param string $userAgent User Agent |
161
|
|
|
*/ |
162
|
|
|
public function __construct(string $userAgent, Detector $detector = null) |
163
|
|
|
{ |
164
|
|
|
$this->os = new Os($this); |
165
|
|
|
$this->device = new Device($this); |
166
|
|
|
$this->browser = new Browser($this); |
167
|
|
|
$this->robot = new Robot($this); |
168
|
|
|
$this->userAgent = $userAgent; |
169
|
|
|
$this->detector = $detector; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* Get result of os detection |
174
|
|
|
* @return Os |
175
|
|
|
*/ |
176
|
|
|
public function getOs(): Os |
177
|
|
|
{ |
178
|
|
|
return $this->os; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Get result of browser detection |
183
|
|
|
* @return Browser |
184
|
|
|
*/ |
185
|
|
|
public function getBrowser(): Browser |
186
|
|
|
{ |
187
|
|
|
return $this->browser; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* Get result of device detection |
192
|
|
|
* @return Device |
193
|
|
|
*/ |
194
|
|
|
public function getDevice(): Device |
195
|
|
|
{ |
196
|
|
|
return $this->device; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* Get result of robot detection |
201
|
|
|
* @return Robot |
202
|
|
|
*/ |
203
|
|
|
public function getRobot(): Robot |
204
|
|
|
{ |
205
|
|
|
return $this->robot; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
public function jsonSerialize() |
209
|
|
|
{ |
210
|
|
|
return get_object_vars($this); |
211
|
|
|
} |
212
|
|
|
} |
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