UserAgentParser\Provider\Http\UserAgentStringCom::parse PHP Method

parse() public method

public parse ( $userAgent, array $headers = [] )
$headers array
    public function parse($userAgent, array $headers = [])
    {
        $resultRaw = $this->getResult($userAgent, $headers);
        /*
         * No result found?
         */
        if ($this->hasResult($resultRaw) !== true) {
            throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent);
        }
        /*
         * 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->hydrateOperatingSystem($result->getOperatingSystem(), $resultRaw);
        return $result;
    }

Usage Example

コード例 #1
0
 public function testEncodeIsCorrect()
 {
     $provider = new UserAgentStringCom($this->getClient());
     $userAgent = 'JUC (Linux; U; 4.0.1; zh-cn; HTC_HD7_4G_T9399+_For_AT&T; 480*800) UCWEB7.9.4.145/139/800';
     $result = $provider->parse($userAgent);
     $this->assertEquals('UC Browser', $result->getBrowser()->getName());
 }
All Usage Examples Of UserAgentParser\Provider\Http\UserAgentStringCom::parse