private function validateResponse(string $url, $content)
    {
        // Throw exception if invalid clientID and/or privateKey used with GoogleMapsBusinessProvider
        if (false !== strpos($content, "Provided 'signature' is not valid for the provided client ID")) {
            throw new InvalidCredentials(sprintf('Invalid client ID / API Key %s', $url));
        }

        $json = json_decode($content);

        // API error
        if (!isset($json)) {
            throw InvalidServerResponse::create($url);
        }

        if ('REQUEST_DENIED' === $json->status && 'The provided API key is invalid.' === $json->error_message) {
            throw new InvalidCredentials(sprintf('API key is invalid %s', $url));
        }

        if ('REQUEST_DENIED' === $json->status) {
            throw new InvalidServerResponse(
                sprintf('API access denied. Request: %s - Message: %s', $url, $json->error_message)
            );
        }

        // you are over your quota
        if ('OVER_QUERY_LIMIT' === $json->status) {
            throw new QuotaExceeded(sprintf('Daily quota exceeded %s', $url));
        }

        return $json;
    }
private function validateResponse(string $url, $content)
    {
        // Throw exception if invalid clientID and/or privateKey used with GoogleMapsBusinessProvider
        if (false !== strpos($content, "Provided 'signature' is not valid for the provided client ID")) {
            throw new InvalidCredentials(sprintf('Invalid client ID / API Key %s', $url));
        }

        $json = json_decode($content);

        // API error
        if (!isset($json)) {
            throw InvalidServerResponse::create($url);
        }

        if ('REQUEST_DENIED' === $json->status && 'The provided API key is invalid.' === $json->error_message) {
            throw new InvalidCredentials(sprintf('API key is invalid %s', $url));
        }

        if ('REQUEST_DENIED' === $json->status) {
            throw new InvalidServerResponse(
                sprintf('API access denied. Request: %s - Message: %s', $url, $json->error_message)
            );
        }

        // you are over your quota
        if ('OVER_QUERY_LIMIT' === $json->status) {
            throw new QuotaExceeded(sprintf('Daily quota exceeded %s', $url));
        }

        return $json;
    }
private function validateResponse ( string $ url , $ content ) { // Throw exception if invalid clientID and/or privateKey used with GoogleMapsBusinessProvider if ( false !== strpos ( $ content , "Provided 'signature' is not valid for the provided client ID" ) ) { throw new InvalidCredentials ( sprintf ( 'Invalid client ID / API Key %s' , $ url ) ) ; } $ json = json_decode ( $ content ) ; // API error if ( ! isset ( $ json ) ) { throw InvalidServerResponse :: create ( $ url ) ; } if ( 'REQUEST_DENIED' === $ json -> status && 'The provided API key is invalid.' === $ json -> error_message ) { throw new InvalidCredentials ( sprintf ( 'API key is invalid %s' , $ url ) ) ; } if ( 'REQUEST_DENIED' === $ json -> status ) { throw new InvalidServerResponse ( sprintf ( 'API access denied. Request: %s - Message: %s' , $ url , $ json -> error_message ) ) ; } // you are over your quota if ( 'OVER_QUERY_LIMIT' === $ json -> status ) { throw new QuotaExceeded ( sprintf ( 'Daily quota exceeded %s' , $ url ) ) ; } return $ json ; }
Decode the response content and validate it to make sure it does not have any errors.

@param string $url
@param string $content

@return mixed result form json_decode()

@throws InvalidCredentials
@throws InvalidServerResponse
@throws QuotaExceeded
Decode the response content and validate it to make sure it does not have any errors .