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

getResult() protected method

protected getResult ( string $userAgent, array $headers ) : stdClass
$userAgent string
$headers array
return stdClass
    protected function getResult($userAgent, array $headers)
    {
        /*
         * an empty UserAgent makes no sense
         */
        if ($userAgent == '') {
            throw new Exception\NoResultFoundException('No result found for user agent: ' . $userAgent);
        }
        $parameters = 'uas=' . rawurlencode($userAgent);
        $parameters .= '&getJSON=all';
        $uri = self::$uri . '?' . $parameters;
        $request = new Request('GET', $uri);
        $response = $this->getResponse($request);
        /*
         * no json returned?
         */
        $contentType = $response->getHeader('Content-Type');
        if (!isset($contentType[0]) || $contentType[0] != 'application/json') {
            throw new Exception\RequestException('Could not get valid "application/json" response from "' . $request->getUri() . '". Response is "' . $response->getBody()->getContents() . '"');
        }
        $content = json_decode($response->getBody()->getContents());
        if (!$content instanceof stdClass) {
            throw new Exception\RequestException('Could not get valid response from "' . $request->getUri() . '". Response is "' . $response->getBody()->getContents() . '"');
        }
        return $content;
    }