/** * */ public function testGetUserAgentWithoutSource() { $object = new Support(); self::assertSame('', $object->getUserAgent()); }
/** * parses the given user agent to get the information about the browser * * if no user agent is given, it uses {@see \BrowscapPHP\Helper\Support} to get it * * @param string $userAgent the user agent string * * @throws \BrowscapPHP\Exception * @return \stdClass the object containing the browsers details. Array if * $return_array is set to true. */ public function getBrowser($userAgent = null) { // Automatically detect the useragent if (!isset($userAgent)) { $support = new Helper\Support($_SERVER); $userAgent = $support->getUserAgent(); } // try to get browser data $formatter = $this->getParser()->getBrowser($userAgent); // if return is still NULL, updates are disabled... in this // case we return an empty formatter instance if ($formatter === null) { return $this->getFormatter()->getData(); } return $formatter->getData(); }
/** * parses the given user agent to get the information about the browser * * if no user agent is given, it uses {@see \BrowscapPHP\Helper\Support} to get it * * @param string $userAgent the user agent string * * @throws \BrowscapPHP\Exception * @return \stdClass the object containing the browsers details. Array if * $return_array is set to true. */ public function getBrowser($userAgent = null) { if (null === $this->getCache()->getVersion()) { // there is no active/warm cache available throw new Exception('there is no active cache available, please run the update command'); } // Automatically detect the useragent if (!isset($userAgent)) { $support = new Helper\Support($_SERVER); $userAgent = $support->getUserAgent(); } // try to get browser data $formatter = $this->getParser()->getBrowser($userAgent); // if return is still NULL, updates are disabled... in this // case we return an empty formatter instance if ($formatter === null) { return $this->getFormatter()->getData(); } return $formatter->getData(); }