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