AbstractDeviceParser.php
1 month ago
Camera.php
2 years ago
CarBrowser.php
2 years ago
Console.php
2 years ago
HbbTv.php
3 months ago
Mobile.php
2 years ago
Notebook.php
2 years ago
PortableMediaPlayer.php
2 years ago
ShellTv.php
3 months ago
ShellTv.php
62 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\Device; |
| 12 | |
| 13 | /** |
| 14 | * Class ShellTv |
| 15 | * @internal |
| 16 | */ |
| 17 | class ShellTv extends AbstractDeviceParser |
| 18 | { |
| 19 | /** |
| 20 | * @var string |
| 21 | */ |
| 22 | protected $fixtureFile = 'regexes/device/shell_tv.yml'; |
| 23 | /** |
| 24 | * @var string |
| 25 | */ |
| 26 | protected $parserName = 'shelltv'; |
| 27 | /** |
| 28 | * Returns if the parsed UA was identified as ShellTv device |
| 29 | * |
| 30 | * @return bool |
| 31 | * |
| 32 | * @throws \Exception |
| 33 | */ |
| 34 | public function isShellTv() : bool |
| 35 | { |
| 36 | $regex = '[a-z]+[ _]Shell[ _]\\w{6}|tclwebkit(\\d+[.\\d]*)'; |
| 37 | $match = $this->matchUserAgent($regex); |
| 38 | return null !== $match; |
| 39 | } |
| 40 | /** |
| 41 | * Parses the current UA and checks whether it contains ShellTv information |
| 42 | * |
| 43 | * @return array|null |
| 44 | * |
| 45 | * @throws \Exception |
| 46 | * |
| 47 | * @see shell_tv.yml for list of detected televisions |
| 48 | * |
| 49 | */ |
| 50 | public function parse() : ?array |
| 51 | { |
| 52 | // only parse user agents containing fragments: {brand} shell |
| 53 | if (!$this->isShellTv()) { |
| 54 | return null; |
| 55 | } |
| 56 | parent::parse(); |
| 57 | // always set device type to tv, even if no model/brand could be found |
| 58 | $this->deviceType = self::DEVICE_TYPE_TV; |
| 59 | return $this->getResult(); |
| 60 | } |
| 61 | } |
| 62 |