independent-analytics
/
vendor
/
matomo
/
device-detector
/
Parser
/
Client
/
Hints
/
BrowserHints.php
independent-analytics
/
vendor
/
matomo
/
device-detector
/
Parser
/
Client
/
Hints
Last commit date
AppHints.php
2 years ago
BrowserHints.php
2 years ago
BrowserHints.php
43 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Device Detector - The Universal Device Detection library for parsing User Agents |
| 5 | * |
| 6 | * @link https://matomo.org |
| 7 | * |
| 8 | * @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later |
| 9 | */ |
| 10 | declare (strict_types=1); |
| 11 | namespace IAWPSCOPED\DeviceDetector\Parser\Client\Hints; |
| 12 | |
| 13 | use IAWPSCOPED\DeviceDetector\Parser\AbstractParser; |
| 14 | /** @internal */ |
| 15 | class BrowserHints extends AbstractParser |
| 16 | { |
| 17 | /** |
| 18 | * @var string |
| 19 | */ |
| 20 | protected $fixtureFile = 'regexes/client/hints/browsers.yml'; |
| 21 | /** |
| 22 | * @var string |
| 23 | */ |
| 24 | protected $parserName = 'BrowserHints'; |
| 25 | /** |
| 26 | * Get browser name if is in collection |
| 27 | * |
| 28 | * @return array|null |
| 29 | */ |
| 30 | public function parse() : ?array |
| 31 | { |
| 32 | if (null === $this->clientHints) { |
| 33 | return null; |
| 34 | } |
| 35 | $appId = $this->clientHints->getApp(); |
| 36 | $name = $this->getRegexes()[$appId] ?? null; |
| 37 | if ('' === (string) $name) { |
| 38 | return null; |
| 39 | } |
| 40 | return ['name' => $name]; |
| 41 | } |
| 42 | } |
| 43 |