1*d5ef99ddSAndreas Gohr<?php 2*d5ef99ddSAndreas Gohr 3*d5ef99ddSAndreas Gohr/** 4*d5ef99ddSAndreas Gohr * Device Detector - The Universal Device Detection library for parsing User Agents 5*d5ef99ddSAndreas Gohr * 6*d5ef99ddSAndreas Gohr * @link https://matomo.org 7*d5ef99ddSAndreas Gohr * 8*d5ef99ddSAndreas Gohr * @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later 9*d5ef99ddSAndreas Gohr */ 10*d5ef99ddSAndreas Gohr 11*d5ef99ddSAndreas Gohrdeclare(strict_types=1); 12*d5ef99ddSAndreas Gohr 13*d5ef99ddSAndreas Gohrnamespace DeviceDetector\Parser\Device; 14*d5ef99ddSAndreas Gohr 15*d5ef99ddSAndreas Gohr/** 16*d5ef99ddSAndreas Gohr * Class ShellTv 17*d5ef99ddSAndreas Gohr */ 18*d5ef99ddSAndreas Gohrclass ShellTv extends AbstractDeviceParser 19*d5ef99ddSAndreas Gohr{ 20*d5ef99ddSAndreas Gohr /** 21*d5ef99ddSAndreas Gohr * @var string 22*d5ef99ddSAndreas Gohr */ 23*d5ef99ddSAndreas Gohr protected $fixtureFile = 'regexes/device/shell_tv.yml'; 24*d5ef99ddSAndreas Gohr 25*d5ef99ddSAndreas Gohr /** 26*d5ef99ddSAndreas Gohr * @var string 27*d5ef99ddSAndreas Gohr */ 28*d5ef99ddSAndreas Gohr protected $parserName = 'shelltv'; 29*d5ef99ddSAndreas Gohr 30*d5ef99ddSAndreas Gohr /** 31*d5ef99ddSAndreas Gohr * Returns if the parsed UA was identified as ShellTv device 32*d5ef99ddSAndreas Gohr * 33*d5ef99ddSAndreas Gohr * @return bool 34*d5ef99ddSAndreas Gohr * 35*d5ef99ddSAndreas Gohr * @throws \Exception 36*d5ef99ddSAndreas Gohr */ 37*d5ef99ddSAndreas Gohr public function isShellTv(): bool 38*d5ef99ddSAndreas Gohr { 39*d5ef99ddSAndreas Gohr $regex = '[a-z]+[ _]Shell[ _]\w{6}|tclwebkit(\d+[.\d]*)'; 40*d5ef99ddSAndreas Gohr $match = $this->matchUserAgent($regex); 41*d5ef99ddSAndreas Gohr 42*d5ef99ddSAndreas Gohr return null !== $match; 43*d5ef99ddSAndreas Gohr } 44*d5ef99ddSAndreas Gohr 45*d5ef99ddSAndreas Gohr /** 46*d5ef99ddSAndreas Gohr * Parses the current UA and checks whether it contains ShellTv information 47*d5ef99ddSAndreas Gohr * 48*d5ef99ddSAndreas Gohr * @see shell_tv.yml for list of detected televisions 49*d5ef99ddSAndreas Gohr * 50*d5ef99ddSAndreas Gohr * @return array|null 51*d5ef99ddSAndreas Gohr */ 52*d5ef99ddSAndreas Gohr public function parse(): ?array 53*d5ef99ddSAndreas Gohr { 54*d5ef99ddSAndreas Gohr // only parse user agents containing fragments: {brand} shell 55*d5ef99ddSAndreas Gohr if (false === $this->isShellTv()) { 56*d5ef99ddSAndreas Gohr return null; 57*d5ef99ddSAndreas Gohr } 58*d5ef99ddSAndreas Gohr 59*d5ef99ddSAndreas Gohr parent::parse(); 60*d5ef99ddSAndreas Gohr 61*d5ef99ddSAndreas Gohr // always set device type to tv, even if no model/brand could be found 62*d5ef99ddSAndreas Gohr $this->deviceType = self::DEVICE_TYPE_TV; 63*d5ef99ddSAndreas Gohr 64*d5ef99ddSAndreas Gohr return $this->getResult(); 65*d5ef99ddSAndreas Gohr } 66*d5ef99ddSAndreas Gohr} 67