/** * */ 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()); }
/** * @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']; }
/** * @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); }