1 | <?php |
||
20 | class Browscap |
||
21 | { |
||
22 | const VERSION = '3.0.0'; |
||
23 | |||
24 | /** |
||
25 | * @var ParserInterface |
||
26 | */ |
||
27 | protected $parser; |
||
28 | |||
29 | /** |
||
30 | * @var FormatterInterface |
||
31 | */ |
||
32 | protected $formatter; |
||
33 | |||
34 | /** |
||
35 | * Update probability percentage, so a value of 1 would check for updates in |
||
36 | * 1% of the requests. A value of 0 disables automatic updates (default). |
||
37 | * |
||
38 | * @var int |
||
39 | */ |
||
40 | protected $autoUpdateProbability = 0; |
||
41 | |||
42 | /** |
||
43 | * @return ParserInterface |
||
44 | * @throws ParserConfigurationException |
||
45 | */ |
||
46 | public function getParser() : ParserInterface |
||
54 | |||
55 | /** |
||
56 | * @param ParserInterface $parser |
||
57 | * |
||
58 | * @return Browscap |
||
59 | */ |
||
60 | public function setParser(ParserInterface $parser) : Browscap |
||
66 | |||
67 | /** |
||
68 | * @return FormatterInterface |
||
69 | */ |
||
70 | public function getFormatter() : FormatterInterface |
||
78 | |||
79 | /** |
||
80 | * @param FormatterInterface $formatter |
||
81 | * |
||
82 | * @return Browscap |
||
83 | */ |
||
84 | public function setFormatter(FormatterInterface $formatter) : Browscap |
||
90 | |||
91 | /** |
||
92 | * @return int |
||
93 | */ |
||
94 | public function getAutoUpdateProbability() : int |
||
98 | |||
99 | /** |
||
100 | * @param int $autoUpdateProbability |
||
101 | * |
||
102 | * @return Browscap |
||
103 | */ |
||
104 | public function setAutoUpdateProbability(int $autoUpdateProbability) : Browscap |
||
110 | |||
111 | /** |
||
112 | * @param string|null $userAgent |
||
113 | * |
||
114 | * @return mixed |
||
115 | * @throws ParserConfigurationException |
||
116 | * @throws ParserRuntimeException |
||
117 | */ |
||
118 | public function getBrowser(string $userAgent = null) |
||
132 | |||
133 | /** |
||
134 | * @return Browscap |
||
135 | * @throws ParserConfigurationException |
||
136 | * @throws ParserRuntimeException |
||
137 | */ |
||
138 | protected function autoUpdate() : Browscap |
||
147 | |||
148 | /** |
||
149 | * Updates Browscap data. Returns a boolean indicating if an update has been done or |
||
150 | * not (because not required). If the option 'forceUpdate' is used, the update is always |
||
151 | * done, no matter if required or not. |
||
152 | * |
||
153 | * @param bool $forceUpdate |
||
154 | * |
||
155 | * @return bool |
||
156 | * @throws ParserConfigurationException |
||
157 | * @throws ParserRuntimeException |
||
158 | */ |
||
159 | public function update(bool $forceUpdate = false) : bool |
||
192 | |||
193 | /** |
||
194 | * Use the class instance as a function that exactly behaves like PHP get_browser(). |
||
195 | * |
||
196 | * @param string $userAgent |
||
197 | * @param bool $returnArray |
||
198 | * |
||
199 | * @return mixed |
||
200 | * @throws ParserConfigurationException |
||
201 | * @throws ParserRuntimeException |
||
202 | */ |
||
203 | public function __invoke(string $userAgent, bool $returnArray = false) |
||
208 | } |
||
209 |