Author: Thomas Müller (t_mueller_stolzenhain@yahoo.de)
 /**
  *
  */
 public function testGetUserAgentWithoutSource()
 {
     $object = new Support();
     self::assertSame('', $object->getUserAgent());
 }
Exemple #2
0
 /**
  * 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();
 }
Exemple #3
0
 /**
  * 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();
 }