| @@ 211-249 (lines=39) @@ | ||
| 208 | } |
|
| 209 | } |
|
| 210 | ||
| 211 | public function parse($userAgent, array $headers = []) |
|
| 212 | { |
|
| 213 | $parser = $this->getParser(); |
|
| 214 | ||
| 215 | /* @var $resultRaw \stdClass */ |
|
| 216 | $resultRaw = $parser->getBrowser($userAgent); |
|
| 217 | ||
| 218 | /* |
|
| 219 | * No result found? |
|
| 220 | */ |
|
| 221 | if ($this->hasResult($resultRaw) !== true) { |
|
| 222 | throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent); |
|
| 223 | } |
|
| 224 | ||
| 225 | /* |
|
| 226 | * Hydrate the model |
|
| 227 | */ |
|
| 228 | $result = new Model\UserAgent(); |
|
| 229 | $result->setProviderResultRaw($resultRaw); |
|
| 230 | ||
| 231 | /* |
|
| 232 | * Bot detection (does only work with full_php_browscap.ini) |
|
| 233 | */ |
|
| 234 | if ($this->isBot($resultRaw) === true) { |
|
| 235 | $this->hydrateBot($result->getBot(), $resultRaw); |
|
| 236 | ||
| 237 | return $result; |
|
| 238 | } |
|
| 239 | ||
| 240 | /* |
|
| 241 | * hydrate the result |
|
| 242 | */ |
|
| 243 | $this->hydrateBrowser($result->getBrowser(), $resultRaw); |
|
| 244 | $this->hydrateRenderingEngine($result->getRenderingEngine(), $resultRaw); |
|
| 245 | $this->hydrateOperatingSystem($result->getOperatingSystem(), $resultRaw); |
|
| 246 | $this->hydrateDevice($result->getDevice(), $resultRaw); |
|
| 247 | ||
| 248 | return $result; |
|
| 249 | } |
|
| 250 | } |
|
| 251 | ||
| @@ 184-222 (lines=39) @@ | ||
| 181 | } |
|
| 182 | } |
|
| 183 | ||
| 184 | public function parse($userAgent, array $headers = []) |
|
| 185 | { |
|
| 186 | $parser = $this->getParser(); |
|
| 187 | ||
| 188 | /* @var $resultRaw \UAParser\Result\Client */ |
|
| 189 | $resultRaw = $parser->parse($userAgent); |
|
| 190 | ||
| 191 | /* |
|
| 192 | * No result found? |
|
| 193 | */ |
|
| 194 | if ($this->hasResult($resultRaw) !== true) { |
|
| 195 | throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent); |
|
| 196 | } |
|
| 197 | ||
| 198 | /* |
|
| 199 | * Hydrate the model |
|
| 200 | */ |
|
| 201 | $result = new Model\UserAgent(); |
|
| 202 | $result->setProviderResultRaw($resultRaw); |
|
| 203 | ||
| 204 | /* |
|
| 205 | * Bot detection |
|
| 206 | */ |
|
| 207 | if ($this->isBot($resultRaw) === true) { |
|
| 208 | $this->hydrateBot($result->getBot(), $resultRaw); |
|
| 209 | ||
| 210 | return $result; |
|
| 211 | } |
|
| 212 | ||
| 213 | /* |
|
| 214 | * Browser |
|
| 215 | */ |
|
| 216 | $this->hydrateBrowser($result->getBrowser(), $resultRaw); |
|
| 217 | // renderingEngine is currently not possible |
|
| 218 | $this->hydrateOperatingSystem($result->getOperatingSystem(), $resultRaw); |
|
| 219 | $this->hydrateDevice($result->getDevice(), $resultRaw); |
|
| 220 | ||
| 221 | return $result; |
|
| 222 | } |
|
| 223 | } |
|
| 224 | ||
| @@ 156-193 (lines=38) @@ | ||
| 153 | return false; |
|
| 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 supported |
|
| 189 | // operatingSystem - not supported (filled OS is mixed! Examples: iPod, iPhone, Android...) |
|
| 190 | $this->hydrateDevice($result->getDevice(), $resultRaw); |
|
| 191 | ||
| 192 | return $result; |
|
| 193 | } |
|
| 194 | } |
|
| 195 | ||