| @@ 156-193 (lines=38) @@ | ||
| 153 | } |
|
| 154 | } |
|
| 155 | ||
| 156 | public function parse($userAgent, array $headers = []) |
|
| 157 | { |
|
| 158 | $parser = $this->getParser(); |
|
| 159 | ||
| 160 | $resultRaw = $parser->parse($userAgent); |
|
| 161 | ||
| 162 | /* |
|
| 163 | * No result found? |
|
| 164 | */ |
|
| 165 | if ($this->hasResult($resultRaw) !== true) { |
|
| 166 | throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent); |
|
| 167 | } |
|
| 168 | ||
| 169 | /* |
|
| 170 | * Hydrate the model |
|
| 171 | */ |
|
| 172 | $result = new Model\UserAgent(); |
|
| 173 | $result->setProviderResultRaw($resultRaw); |
|
| 174 | ||
| 175 | /* |
|
| 176 | * Bot detection |
|
| 177 | */ |
|
| 178 | if ($this->isBot($resultRaw) === true) { |
|
| 179 | $this->hydrateBot($result->getBot(), $resultRaw); |
|
| 180 | ||
| 181 | return $result; |
|
| 182 | } |
|
| 183 | ||
| 184 | /* |
|
| 185 | * hydrate the result |
|
| 186 | */ |
|
| 187 | $this->hydrateBrowser($result->getBrowser(), $resultRaw); |
|
| 188 | // renderingEngine not available |
|
| 189 | // operatingSystem filled OS is mixed! Examples: iPod, iPhone, Android... |
|
| 190 | $this->hydrateDevice($result->getDevice(), $resultRaw); |
|
| 191 | ||
| 192 | return $result; |
|
| 193 | } |
|
| 194 | } |
|
| 195 | ||
| @@ 243-281 (lines=39) @@ | ||
| 240 | } |
|
| 241 | } |
|
| 242 | ||
| 243 | public function parse($userAgent, array $headers = []) |
|
| 244 | { |
|
| 245 | $parser = $this->getParser(); |
|
| 246 | ||
| 247 | /* @var $resultRaw \stdClass */ |
|
| 248 | $resultRaw = $parser->getBrowser($userAgent); |
|
| 249 | ||
| 250 | /* |
|
| 251 | * No result found? |
|
| 252 | */ |
|
| 253 | if ($this->hasResult($resultRaw) !== true) { |
|
| 254 | throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent); |
|
| 255 | } |
|
| 256 | ||
| 257 | /* |
|
| 258 | * Hydrate the model |
|
| 259 | */ |
|
| 260 | $result = new Model\UserAgent(); |
|
| 261 | $result->setProviderResultRaw($resultRaw); |
|
| 262 | ||
| 263 | /* |
|
| 264 | * Bot detection (does only work with full_php_browscap.ini) |
|
| 265 | */ |
|
| 266 | if ($this->isBot($resultRaw) === true) { |
|
| 267 | $this->hydrateBot($result->getBot(), $resultRaw); |
|
| 268 | ||
| 269 | return $result; |
|
| 270 | } |
|
| 271 | ||
| 272 | /* |
|
| 273 | * hydrate the result |
|
| 274 | */ |
|
| 275 | $this->hydrateBrowser($result->getBrowser(), $resultRaw); |
|
| 276 | $this->hydrateRenderingEngine($result->getRenderingEngine(), $resultRaw); |
|
| 277 | $this->hydrateOperatingSystem($result->getOperatingSystem(), $resultRaw); |
|
| 278 | $this->hydrateDevice($result->getDevice(), $resultRaw); |
|
| 279 | ||
| 280 | return $result; |
|
| 281 | } |
|
| 282 | } |
|
| 283 | ||