@@ -53,13 +53,11 @@ |
||
53 | 53 | * @class OsDetector |
54 | 54 | * @package Platine\UserAgent\Detector |
55 | 55 | */ |
56 | -class OsDetector extends AbstractDetector |
|
57 | -{ |
|
56 | +class OsDetector extends AbstractDetector { |
|
58 | 57 | /** |
59 | 58 | * {@inheritdoc} |
60 | 59 | */ |
61 | - public function __construct() |
|
62 | - { |
|
60 | + public function __construct() { |
|
63 | 61 | parent::__construct(); |
64 | 62 | |
65 | 63 | $this->entity = new Os(); |
@@ -53,13 +53,11 @@ |
||
53 | 53 | * @class CpuDetector |
54 | 54 | * @package Platine\UserAgent\Detector |
55 | 55 | */ |
56 | -class CpuDetector extends AbstractDetector |
|
57 | -{ |
|
56 | +class CpuDetector extends AbstractDetector { |
|
58 | 57 | /** |
59 | 58 | * {@inheritdoc} |
60 | 59 | */ |
61 | - public function __construct() |
|
62 | - { |
|
60 | + public function __construct() { |
|
63 | 61 | parent::__construct(); |
64 | 62 | |
65 | 63 | $this->entity = new Cpu(); |
@@ -53,13 +53,11 @@ |
||
53 | 53 | * @class EngineDetector |
54 | 54 | * @package Platine\UserAgent\Detector |
55 | 55 | */ |
56 | -class EngineDetector extends AbstractDetector |
|
57 | -{ |
|
56 | +class EngineDetector extends AbstractDetector { |
|
58 | 57 | /** |
59 | 58 | * {@inheritdoc} |
60 | 59 | */ |
61 | - public function __construct() |
|
62 | - { |
|
60 | + public function __construct() { |
|
63 | 61 | parent::__construct(); |
64 | 62 | |
65 | 63 | $this->entity = new Engine(); |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | return [ |
95 | 95 | [ |
96 | 96 | // Presto based |
97 | - '/(opera\smini)\/([\w\.-]+)/i', // Opera Mini |
|
98 | - '/(opera\s[mobiletab]+).+version\/([\w\.-]+)/i', // Opera Mobi/Tablet |
|
99 | - '/(opera).+version\/([\w\.]+)/i', // Opera > 9.80 |
|
97 | + '/(opera\smini)\/([\w\.-]+)/i', // Opera Mini |
|
98 | + '/(opera\s[mobiletab]+).+version\/([\w\.-]+)/i', // Opera Mobi/Tablet |
|
99 | + '/(opera).+version\/([\w\.]+)/i', // Opera > 9.80 |
|
100 | 100 | '/(opera)[\/\s]+([\w\.]+)/i' // Opera < 9.80 |
101 | 101 | ], [self::NAME, self::VERSION], [ |
102 | 102 | '/(opios)[\/\s]+([\w\.]+)/i' // Opera mini on iphone >= 8.0 |
@@ -104,18 +104,18 @@ discard block |
||
104 | 104 | '/\s(opr)\/([\w\.]+)/i' // Opera Webkit |
105 | 105 | ], [[self::NAME, 'Opera'], self::VERSION], [ |
106 | 106 | // Mixed |
107 | - '/(kindle)\/([\w\.]+)/i', // Kindle |
|
107 | + '/(kindle)\/([\w\.]+)/i', // Kindle |
|
108 | 108 | '/(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]*)/i', |
109 | 109 | // Lunascape/Maxthon/Netfront/Jasmine/Blazer |
110 | 110 | |
111 | 111 | // Trident based |
112 | 112 | '/(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?([\w\.]*)/i', |
113 | 113 | // Avant/IEMobile/SlimBrowser/Baidu |
114 | - '/(?:ms|\()(ie)\s([\w\.]+)/i', // Internet Explorer |
|
114 | + '/(?:ms|\()(ie)\s([\w\.]+)/i', // Internet Explorer |
|
115 | 115 | |
116 | 116 | // Webkit/KHTML based |
117 | - '/(rekonq)\/([\w\.]*)/i', // Rekonq |
|
118 | - '/(Instagram)\s([\w\.]+)/i', // Instagram inApp Browser |
|
117 | + '/(rekonq)\/([\w\.]*)/i', // Rekonq |
|
118 | + '/(Instagram)\s([\w\.]+)/i', // Instagram inApp Browser |
|
119 | 119 | '/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon)\/([\w\.-]+)/i' |
120 | 120 | // Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser/QupZilla/Falkon |
121 | 121 | ], [self::NAME, self::VERSION], [ |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | '/;(fbav)\/([\w\.]+);/i' // Facebook App for iOS & Android |
179 | 179 | ], [[self::NAME, 'Facebook'], self::VERSION], [ |
180 | 180 | |
181 | - '/safari\s(line)\/([\w\.]+)/i', // Line App for iOS |
|
181 | + '/safari\s(line)\/([\w\.]+)/i', // Line App for iOS |
|
182 | 182 | '/android.+(line)\/([\w\.]+)\/iab/i' // Line App for Android |
183 | 183 | ], [self::NAME, self::VERSION], [ |
184 | 184 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | ], [[self::NAME, '/(.+)/', '$1 WebView'], self::VERSION], [ |
190 | 190 | |
191 | 191 | '/((?:oculus|samsung)browser)\/([\w\.]+)/i' |
192 | - ], [[self::NAME, "/(.+(?:g|us))(.+)/", '$1 $2'], self::VERSION], [ // Oculus / Samsung Browser |
|
192 | + ], [[self::NAME, "/(.+(?:g|us))(.+)/", '$1 $2'], self::VERSION], [// Oculus / Samsung Browser |
|
193 | 193 | |
194 | 194 | '/android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)*/i' // Android Browser |
195 | 195 | ], [self::VERSION, [self::NAME, 'Android Browser']], [ |
@@ -231,20 +231,20 @@ discard block |
||
231 | 231 | // Gecko based |
232 | 232 | '/(navigator|netscape)\/([\w\.-]+)/i' // Netscape |
233 | 233 | ], [[self::NAME, 'Netscape'], self::VERSION], [ |
234 | - '/(swiftfox)/i', // Swiftfox |
|
234 | + '/(swiftfox)/i', // Swiftfox |
|
235 | 235 | '/(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i', |
236 | 236 | // IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror |
237 | 237 | '/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([\w\.-]+)$/i', |
238 | 238 | |
239 | 239 | // Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix |
240 | - '/(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i', // Mozilla |
|
240 | + '/(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i', // Mozilla |
|
241 | 241 | |
242 | 242 | // Other |
243 | 243 | '/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir)[\/\s]?([\w\.]+)/i', |
244 | 244 | // Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Sleipnir |
245 | - '/(links)\s\(([\w\.]+)/i', // Links |
|
246 | - '/(gobrowser)\/?([\w\.]*)/i', // GoBrowser |
|
247 | - '/(ice\s?browser)\/v?([\w\._]+)/i', // ICE Browser |
|
245 | + '/(links)\s\(([\w\.]+)/i', // Links |
|
246 | + '/(gobrowser)\/?([\w\.]*)/i', // GoBrowser |
|
247 | + '/(ice\s?browser)\/v?([\w\._]+)/i', // ICE Browser |
|
248 | 248 | '/(mosaic)[\/\s]([\w\.]+)/i' // Mosaic |
249 | 249 | ], [self::NAME, self::VERSION], |
250 | 250 | ]; |
@@ -53,13 +53,11 @@ |
||
53 | 53 | * @class BrowserDetector |
54 | 54 | * @package Platine\UserAgent\Detector |
55 | 55 | */ |
56 | -class BrowserDetector extends AbstractDetector |
|
57 | -{ |
|
56 | +class BrowserDetector extends AbstractDetector { |
|
58 | 57 | /** |
59 | 58 | * {@inheritdoc} |
60 | 59 | */ |
61 | - public function __construct() |
|
62 | - { |
|
60 | + public function __construct() { |
|
63 | 61 | parent::__construct(); |
64 | 62 | |
65 | 63 | $this->entity = new Browser(); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * The current entity |
93 | 93 | * @var Browser|Cpu|Os|Device|Engine |
94 | 94 | */ |
95 | - protected Browser|Cpu|Os|Device|Engine $entity; |
|
95 | + protected Browser | Cpu | Os | Device | Engine $entity; |
|
96 | 96 | |
97 | 97 | /** |
98 | 98 | * Create new instance |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $match = ''; |
117 | 117 | $matches = []; |
118 | 118 | |
119 | - while ($i < $regexLength && ! $matches) { |
|
119 | + while ($i < $regexLength && !$matches) { |
|
120 | 120 | $reg = $regex[$i]; |
121 | 121 | $property = $regex[$i + 1]; |
122 | 122 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $k = 0; |
125 | 125 | |
126 | 126 | $regLength = count($reg); |
127 | - while ($j < $regLength && ! $matches) { |
|
127 | + while ($j < $regLength && !$matches) { |
|
128 | 128 | $pattern = $reg[$j++]; |
129 | 129 | if (is_string($pattern)) { |
130 | 130 | preg_match($pattern, $userAgent, $matches); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | $this->fillEntity([$q[0] => $result]); |
167 | 167 | } else { |
168 | - $replacedMatch = preg_replace($q[1], $q[2], (string)$match); |
|
168 | + $replacedMatch = preg_replace($q[1], $q[2], (string) $match); |
|
169 | 169 | if ($replacedMatch !== null) { |
170 | 170 | $this->fillEntity([$q[0] => $replacedMatch]); |
171 | 171 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | } elseif (count($q) === 4) { |
174 | 174 | if (Helper::startsWith($q[3], '__')) { |
175 | 175 | $functionName = Helper::replaceFirst('__', '', $q[3]); |
176 | - $result = preg_replace($q[1], $q[2], (string)$match); |
|
176 | + $result = preg_replace($q[1], $q[2], (string) $match); |
|
177 | 177 | if (method_exists($this, $functionName)) { |
178 | 178 | $result = $this->{$functionName}($result); |
179 | 179 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * Return the entity instance |
197 | 197 | * @return Browser|Cpu|Os|Device|Engine |
198 | 198 | */ |
199 | - public function entity(): Browser|Cpu|Os|Device|Engine |
|
199 | + public function entity(): Browser | Cpu | Os | Device | Engine |
|
200 | 200 | { |
201 | 201 | return $this->entity; |
202 | 202 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @param string $str |
243 | 243 | * @return string|string[]|null |
244 | 244 | */ |
245 | - protected function trim(string $str): string|array|null |
|
245 | + protected function trim(string $str): string | array | null |
|
246 | 246 | { |
247 | 247 | return preg_replace( |
248 | 248 | '/^[\s\xA0]+|[\s\xA0]+$/', |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | * @class AbstractDetector |
59 | 59 | * @package Platine\UserAgent\Detector |
60 | 60 | */ |
61 | -abstract class AbstractDetector |
|
62 | -{ |
|
61 | +abstract class AbstractDetector { |
|
63 | 62 | /** |
64 | 63 | * Data type and definitions |
65 | 64 | */ |
@@ -97,8 +96,7 @@ discard block |
||
97 | 96 | /** |
98 | 97 | * Create new instance |
99 | 98 | */ |
100 | - public function __construct() |
|
101 | - { |
|
99 | + public function __construct() { |
|
102 | 100 | $this->maps = $this->maps(); |
103 | 101 | $this->regex = $this->regex(); |
104 | 102 | } |
@@ -53,13 +53,11 @@ |
||
53 | 53 | * @class DeviceDetector |
54 | 54 | * @package Platine\UserAgent\Detector |
55 | 55 | */ |
56 | -class DeviceDetector extends AbstractDetector |
|
57 | -{ |
|
56 | +class DeviceDetector extends AbstractDetector { |
|
58 | 57 | /** |
59 | 58 | * {@inheritdoc} |
60 | 59 | */ |
61 | - public function __construct() |
|
62 | - { |
|
60 | + public function __construct() { |
|
63 | 61 | parent::__construct(); |
64 | 62 | |
65 | 63 | $this->entity = new Device(); |
@@ -62,8 +62,7 @@ discard block |
||
62 | 62 | * @class UserAgent |
63 | 63 | * @package Platine\UserAgent |
64 | 64 | */ |
65 | -class UserAgent |
|
66 | -{ |
|
65 | +class UserAgent { |
|
67 | 66 | /** |
68 | 67 | * Operating System detector |
69 | 68 | * @var OsDetector |
@@ -134,8 +133,7 @@ discard block |
||
134 | 133 | * Create new instance |
135 | 134 | * @param string|null $userAgent |
136 | 135 | */ |
137 | - public function __construct(?string $userAgent = null) |
|
138 | - { |
|
136 | + public function __construct(?string $userAgent = null) { |
|
139 | 137 | $this->browserDetector = new BrowserDetector(); |
140 | 138 | $this->cpuDetector = new CpuDetector(); |
141 | 139 | $this->engineDetector = new EngineDetector(); |
@@ -51,8 +51,7 @@ |
||
51 | 51 | * @class Helper |
52 | 52 | * @package Platine\UserAgent\Util |
53 | 53 | */ |
54 | -class Helper |
|
55 | -{ |
|
54 | +class Helper { |
|
56 | 55 | /** |
57 | 56 | * Return the major version number from the full version |
58 | 57 | * @param string $fullVersion |
@@ -51,6 +51,5 @@ |
||
51 | 51 | * @class Engine |
52 | 52 | * @package Platine\UserAgent\Entity |
53 | 53 | */ |
54 | -class Engine extends BaseEntity |
|
55 | -{ |
|
54 | +class Engine extends BaseEntity { |
|
56 | 55 | } |