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
11declare(strict_types=1);
12
13namespace DeviceDetector\Parser\Client\Hints;
14
15use DeviceDetector\Parser\AbstractParser;
16
17class AppHints extends AbstractParser
18{
19    /**
20     * @var string
21     */
22    protected $fixtureFile = 'regexes/client/hints/apps.yml';
23
24    /**
25     * @var string
26     */
27    protected $parserName = 'AppHints';
28
29    /**
30     * Get application name if is in collection
31     *
32     * @return array|null
33     */
34    public function parse(): ?array
35    {
36        if (null === $this->clientHints) {
37            return null;
38        }
39
40        $appId = $this->clientHints->getApp();
41        $name  = $this->getRegexes()[$appId] ?? null;
42
43        if ('' === (string) $name) {
44            return null;
45        }
46
47        return [
48            'name' => $name,
49        ];
50    }
51}
52