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