Автор: Thomas Müller (t_mueller_stolzenhain@yahoo.de)
Наследование: extends DomainException
Пример #1
0
 /**
  *
  */
 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());
 }
Пример #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'];
 }
Пример #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);
 }