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.3'; |
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
|
|
|
/** |
78
|
|
|
* @var boolean true if device is touch |
79
|
|
|
*/ |
80
|
|
|
protected $isTouch = false; |
81
|
|
|
/** |
82
|
|
|
* @var boolean true if device is mobile |
83
|
|
|
*/ |
84
|
|
|
protected $isMobile = false; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* True if user is touch |
88
|
|
|
* @return bool |
89
|
|
|
*/ |
90
|
|
|
public function isTouch(): bool |
91
|
|
|
{ |
92
|
|
|
return $this->isTouch; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Setter |
97
|
|
|
* @param bool $isTouch |
98
|
|
|
*/ |
99
|
|
|
public function setIsTouch(bool $isTouch) |
100
|
|
|
{ |
101
|
|
|
$this->isTouch = $isTouch; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* True if user is mobile |
106
|
|
|
* @return bool |
107
|
|
|
*/ |
108
|
|
|
public function isMobile(): bool |
109
|
|
|
{ |
110
|
|
|
return $this->isMobile; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Setter |
115
|
|
|
* @param bool $isMobile |
116
|
|
|
*/ |
117
|
|
|
public function setIsMobile(bool $isMobile) |
118
|
|
|
{ |
119
|
|
|
$this->isMobile = $isMobile; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* True if user is tablet |
124
|
|
|
* @return bool |
125
|
|
|
*/ |
126
|
|
|
public function isTablet(): bool |
127
|
|
|
{ |
128
|
|
|
return $this->isTablet; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Setter |
133
|
|
|
* @param bool $isTablet |
134
|
|
|
*/ |
135
|
|
|
public function setIsTablet(bool $isTablet) |
136
|
|
|
{ |
137
|
|
|
$this->isTablet = $isTablet; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** @var boolean true if user is tablet */ |
141
|
|
|
protected $isTablet = false; |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Result constructor. |
145
|
|
|
* @param string $userAgent User Agent |
146
|
|
|
*/ |
147
|
|
|
public function __construct(string $userAgent, Detector $detector = null) |
148
|
|
|
{ |
149
|
|
|
$this->os = new Os($this); |
150
|
|
|
$this->device = new Device($this); |
151
|
|
|
$this->browser = new Browser($this); |
152
|
|
|
$this->userAgent = $userAgent; |
153
|
|
|
$this->detector = $detector; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Get result of os detection |
158
|
|
|
* @return Os |
159
|
|
|
*/ |
160
|
|
|
public function getOs(): Os |
161
|
|
|
{ |
162
|
|
|
return $this->os; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Get result of browser detection |
167
|
|
|
* @return Browser |
168
|
|
|
*/ |
169
|
|
|
public function getBrowser(): Browser |
170
|
|
|
{ |
171
|
|
|
return $this->browser; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Get result of device detection |
176
|
|
|
* @return Device |
177
|
|
|
*/ |
178
|
|
|
public function getDevice(): Device |
179
|
|
|
{ |
180
|
|
|
return $this->device; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* Get result of robot detection |
185
|
|
|
* @return Robot |
186
|
|
|
*/ |
187
|
|
|
public function getRobot(): Robot |
|
|
|
|
188
|
|
|
{ |
189
|
|
|
return $this->robot; |
|
|
|
|
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
public function jsonSerialize() |
193
|
|
|
{ |
194
|
|
|
return get_object_vars($this); |
195
|
|
|
} |
196
|
|
|
} |
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