1 | <?php |
||
11 | class UserAgentParser |
||
12 | { |
||
13 | private $userAgent; |
||
14 | private $groups = []; |
||
15 | |||
16 | /** |
||
17 | * Constructor |
||
18 | * |
||
19 | * @param string $userAgent |
||
20 | */ |
||
21 | public function __construct($userAgent) |
||
28 | |||
29 | /** |
||
30 | * Validate the UserAgent format |
||
31 | * |
||
32 | * @throws FormatException |
||
33 | */ |
||
34 | protected function checkFormat() |
||
40 | |||
41 | /** |
||
42 | * Parses all possible User-Agent groups to an array |
||
43 | * |
||
44 | * @return array |
||
45 | */ |
||
46 | private function explode() |
||
61 | |||
62 | /** |
||
63 | * Strip version number |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | public function stripVersion() |
||
74 | |||
75 | /** |
||
76 | * Find matching User-Agent |
||
77 | * Selects the best matching from an array, or false if none matches |
||
78 | * |
||
79 | * @param array $array |
||
80 | * @return string|false |
||
81 | */ |
||
82 | public function match($array) |
||
92 | |||
93 | /** |
||
94 | * Export all User-Agents as an array |
||
95 | * |
||
96 | * @return array |
||
97 | */ |
||
98 | public function export() |
||
102 | } |
||
103 |