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