private function validate($apiRawResponse)
    {
        $response = json_decode($apiRawResponse);

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

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

        if (200 !== $response->status_code) {
            throw new InvalidApiResponseException(sprintf('Bit.ly returned status code "%s" with message "%s"',
                $response->status_code,
                property_exists($response, 'status_txt') ? $response->status_txt : ''
            ));
        }

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

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

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

        if (200 !== $response->status_code) {
            throw new InvalidApiResponseException(sprintf('Bit.ly returned status code "%s" with message "%s"',
                $response->status_code,
                property_exists($response, 'status_txt') ? $response->status_txt : ''
            ));
        }

        return $response;
    }
private function validate ( $ apiRawResponse ) { $ response = json_decode ( $ apiRawResponse ) ; if ( null === $ response ) { throw new InvalidApiResponseException ( 'Bit.ly response is probably mal-formed because cannot be json-decoded.' ) ; } if ( ! property_exists ( $ response , 'status_code' ) ) { throw new InvalidApiResponseException ( 'Property "status_code" does not exist within Bit.ly response.' ) ; } if ( 200 !== $ response -> status_code ) { throw new InvalidApiResponseException ( sprintf ( 'Bit.ly returned status code "%s" with message "%s"' , $ response -> status_code , property_exists ( $ response , 'status_txt' ) ? $ response -> status_txt : '' ) ) ; } return $ response ; }
Validates the Bit.ly's response and returns it whether the status code is 200.

@param string $apiRawResponse

@return object

@throws InvalidApiResponseException
Validates the Bit . ly s response and returns it whether the status code is 200 .