src/Mremi/UrlShortener/Provider/Baidu/BaiduProvider.php
private function validate($apiRawResponse, $checkStatus = false)
    {
        $response = json_decode($apiRawResponse);

        if (null === $response) {
            throw new InvalidApiResponseException('Baidu response is probably mal-formed because cannot be json-decoded.');
        }

        if (!$checkStatus) {
            return $response;
        }

        if (!property_exists($response, 'Code')) {
            throw new InvalidApiResponseException('Property "Code" does not exist within Baidu response.');
        }

        if (0 !== $response->Code) {
            throw new InvalidApiResponseException(sprintf('Baidu returned code error message "%s: %s".', $response->Code, $response->ErrMsg));
        }

        return $response;
    }
private function validate($apiRawResponse, $checkStatus = false)
    {
        $response = json_decode($apiRawResponse);

        if (null === $response) {
            throw new InvalidApiResponseException('Baidu response is probably mal-formed because cannot be json-decoded.');
        }

        if (!$checkStatus) {
            return $response;
        }

        if (!property_exists($response, 'Code')) {
            throw new InvalidApiResponseException('Property "Code" does not exist within Baidu response.');
        }

        if (0 !== $response->Code) {
            throw new InvalidApiResponseException(sprintf('Baidu returned code error message "%s: %s".', $response->Code, $response->ErrMsg));
        }

        return $response;
    }
Validates the Google's response and returns it whether the status code is 200.

@param string $apiRawResponse An API response, as it returned
@param bool   $checkStatus    TRUE whether the status code has to be checked, default FALSE

@return object

@throws InvalidApiResponseException