UserAgentParser\Provider\Http\UserAgentApiCom::parse PHP 메소드

parse() 공개 메소드

public parse ( $userAgent, array $headers = [] )
$headers array
    public function parse($userAgent, array $headers = [])
    {
        $resultRaw = $this->getResult($userAgent, $headers);
        /*
         * Hydrate the model
         */
        $result = new Model\UserAgent();
        $result->setProviderResultRaw($resultRaw);
        /*
         * Bot detection
         */
        if ($this->isBot($resultRaw) === true) {
            $this->hydrateBot($result->getBot(), $resultRaw);
            return $result;
        }
        /*
         * hydrate the result
         */
        $this->hydrateBrowser($result->getBrowser(), $resultRaw);
        $this->hydrateRenderingEngine($result->getRenderingEngine(), $resultRaw);
        $this->hydrateDevice($result->getDevice(), $resultRaw);
        return $result;
    }

Usage Example

 /**
  * Device only
  */
 public function testParseDevice()
 {
     $data = new stdClass();
     $data->platform_type = 'mobile';
     $rawResult = new stdClass();
     $rawResult->data = $data;
     $responseQueue = [new Response(200, ['Content-Type' => 'application/json'], json_encode($rawResult))];
     $provider = new UserAgentApiCom($this->getClient($responseQueue), 'apiKey123');
     $result = $provider->parse('A real user agent...');
     $expectedResult = ['device' => ['model' => null, 'brand' => null, 'type' => 'mobile', 'isMobile' => null, 'isTouch' => null]];
     $this->assertProviderResult($result, $expectedResult);
 }
All Usage Examples Of UserAgentParser\Provider\Http\UserAgentApiCom::parse