| 1 | <?php |
||
| 9 | class UserAgentParser |
||
| 10 | { |
||
| 11 | private $userAgent; |
||
| 12 | private $groups = []; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Constructor |
||
| 16 | * |
||
| 17 | * @param string $userAgent |
||
| 18 | */ |
||
| 19 | public function __construct($userAgent) |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Parses all possible User-Agent groups to an array |
||
| 27 | * |
||
| 28 | * @return array |
||
| 29 | */ |
||
| 30 | private function explode() |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Strip version number |
||
| 43 | * |
||
| 44 | * @return string |
||
| 45 | */ |
||
| 46 | public function stripVersion() |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Find matching User-Agent |
||
| 56 | * Selects the best matching from an array, or $fallback if none matches |
||
| 57 | * |
||
| 58 | * @param array $array |
||
| 59 | * @param string|null $fallback |
||
| 60 | * @return string|false |
||
| 61 | */ |
||
| 62 | public function match($array, $fallback = null) |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Export all User-Agents as an array |
||
| 74 | * |
||
| 75 | * @return array |
||
| 76 | */ |
||
| 77 | public function export() |
||
| 81 | } |
||
| 82 |