private function validateResponse($response)
    {
        if (!isset($response)) {
            throw new NoResult(sprintf('Could not execute query'));
        }

        if ('REQUEST_DENIED' === $response['status'] && 'The provided API key is invalid.' === $response['error_message']) {
            throw new InvalidKey(sprintf('API key is invalid'));
        }

        if ('REQUEST_DENIED' === $response['status']) {
            throw new AccessDenied(sprintf('API access denied. Message: %s', $response['error_message']));
        }

        // you are over your quota
        if ('OVER_QUERY_LIMIT' === $response['status']) {
            throw new QuotaExceeded('Daily quota exceeded');
        }

        // no result
        if (!isset($response['results']) || !count($response['results']) || 'OK' !== $response['status']) {
            throw new NoResult('No results for query');
        }

        return $response;
    }
private function validateResponse($response)
    {
        if (!isset($response)) {
            throw new NoResult(sprintf('Could not execute query'));
        }

        if ('REQUEST_DENIED' === $response['status'] && 'The provided API key is invalid.' === $response['error_message']) {
            throw new InvalidKey(sprintf('API key is invalid'));
        }

        if ('REQUEST_DENIED' === $response['status']) {
            throw new AccessDenied(sprintf('API access denied. Message: %s', $response['error_message']));
        }

        // you are over your quota
        if ('OVER_QUERY_LIMIT' === $response['status']) {
            throw new QuotaExceeded('Daily quota exceeded');
        }

        // no result
        if (!isset($response['results']) || !count($response['results']) || 'OK' !== $response['status']) {
            throw new NoResult('No results for query');
        }

        return $response;
    }
private function validateResponse ( $ response ) { if ( ! isset ( $ response ) ) { throw new NoResult ( sprintf ( 'Could not execute query' ) ) ; } if ( 'REQUEST_DENIED' === $ response [ 'status' ] && 'The provided API key is invalid.' === $ response [ 'error_message' ] ) { throw new InvalidKey ( sprintf ( 'API key is invalid' ) ) ; } if ( 'REQUEST_DENIED' === $ response [ 'status' ] ) { throw new AccessDenied ( sprintf ( 'API access denied. Message: %s' , $ response [ 'error_message' ] ) ) ; } // you are over your quota if ( 'OVER_QUERY_LIMIT' === $ response [ 'status' ] ) { throw new QuotaExceeded ( 'Daily quota exceeded' ) ; } // no result if ( ! isset ( $ response [ 'results' ] ) || ! count ( $ response [ 'results' ] ) || 'OK' !== $ response [ 'status' ] ) { throw new NoResult ( 'No results for query' ) ; } return $ response ; }
Makes sure the response does not contain any errors.

@param $response
@return mixed
@throws AccessDenied
@throws InvalidKey
@throws NoResult
@throws QuotaExceeded
Makes sure the response does not contain any errors .