1 | <?php |
||
15 | final class Browscap implements BrowscapInterface |
||
16 | { |
||
17 | /** |
||
18 | * Parser to use |
||
19 | * |
||
20 | * @var \BrowscapPHP\Parser\ParserInterface|null |
||
21 | */ |
||
22 | private $parser; |
||
23 | |||
24 | /** |
||
25 | * Formatter to use |
||
26 | * |
||
27 | * @var \BrowscapPHP\Formatter\FormatterInterface |
||
28 | */ |
||
29 | private $formatter; |
||
30 | |||
31 | /** |
||
32 | * The cache instance |
||
33 | * |
||
34 | * @var \BrowscapPHP\Cache\BrowscapCacheInterface |
||
35 | */ |
||
36 | private $cache; |
||
37 | |||
38 | /** |
||
39 | * @var \Psr\Log\LoggerInterface |
||
40 | */ |
||
41 | private $logger; |
||
42 | |||
43 | /** |
||
44 | * Browscap constructor. |
||
45 | * |
||
46 | * @param \Psr\SimpleCache\CacheInterface $cache |
||
47 | * @param LoggerInterface $logger |
||
48 | */ |
||
49 | 7 | public function __construct(CacheInterface $cache, LoggerInterface $logger) |
|
56 | |||
57 | /** |
||
58 | * Set theformatter instance to use for the getBrowser() result |
||
59 | * |
||
60 | * @param \BrowscapPHP\Formatter\FormatterInterface $formatter |
||
61 | */ |
||
62 | 4 | public function setFormatter(Formatter\FormatterInterface $formatter) : void |
|
66 | |||
67 | /** |
||
68 | * Sets the parser instance to use |
||
69 | * |
||
70 | * @param \BrowscapPHP\Parser\ParserInterface $parser |
||
71 | */ |
||
72 | 4 | public function setParser(ParserInterface $parser) : void |
|
76 | |||
77 | /** |
||
78 | * returns an instance of the used parser class |
||
79 | * |
||
80 | * @return \BrowscapPHP\Parser\ParserInterface |
||
81 | */ |
||
82 | 5 | public function getParser() : ParserInterface |
|
93 | |||
94 | /** |
||
95 | * parses the given user agent to get the information about the browser |
||
96 | * |
||
97 | * if no user agent is given, it uses {@see \BrowscapPHP\Helper\Support} to get it |
||
98 | * |
||
99 | * @param string $userAgent the user agent string |
||
100 | * |
||
101 | * @throws \BrowscapPHP\Exception |
||
102 | * |
||
103 | * @return \stdClass the object containing the browsers details. |
||
104 | */ |
||
105 | public function getBrowser(?string $userAgent = null) : \stdClass |
||
134 | } |
||
135 |