Author: Thomas Müller (t_mueller_stolzenhain@yahoo.de)
Inheritance: extends DomainException
 /**
  *
  */
 public function testUserAgentParserError()
 {
     /** @var \BrowscapPHP\Exception\ReaderException $exception */
     $exception = ReaderException::userAgentParserError(42);
     self::assertInstanceOf('\\BrowscapPHP\\Exception\\ReaderException', $exception);
     self::assertSame('Cannot extract user agent string from line "42"', $exception->getMessage());
 }
Esempio n. 2
0
 /**
  * @param string $line
  *
  * @throws \BrowscapPHP\Exception\ReaderException
  * @return string
  */
 public function read($line)
 {
     $matches = $this->match($line);
     if (!isset($matches['userAgentString'])) {
         throw ReaderException::userAgentParserError($line);
     }
     return $matches['userAgentString'];
 }
Esempio n. 3
0
 /**
  * @param string $line
  *
  * @throws \BrowscapPHP\Exception\ReaderException
  * @return string
  */
 public function read($line)
 {
     foreach ($this->readers as $reader) {
         if ($reader->test($line)) {
             return $reader->read($line);
         }
     }
     throw ReaderException::userAgentParserError($line);
 }