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; 14 15/** 16 * Class VendorFragments 17 * 18 * Device parser for vendor fragment detection 19 */ 20class VendorFragment extends AbstractParser 21{ 22 /** 23 * @var string 24 */ 25 protected $fixtureFile = 'regexes/vendorfragments.yml'; 26 27 /** 28 * @var string 29 */ 30 protected $parserName = 'vendorfragments'; 31 32 /** 33 * @var string 34 */ 35 protected $matchedRegex = null; 36 37 /** 38 * @inheritdoc 39 */ 40 public function parse(): ?array 41 { 42 foreach ($this->getRegexes() as $brand => $regexes) { 43 foreach ($regexes as $regex) { 44 if ($this->matchUserAgent($regex . '[^a-z0-9]+')) { 45 $this->matchedRegex = $regex; 46 47 return ['brand' => $brand]; 48 } 49 } 50 } 51 52 return null; 53 } 54 55 /** 56 * @return string|null 57 */ 58 public function getMatchedRegex(): ?string 59 { 60 return $this->matchedRegex; 61 } 62} 63