src/TheTVDbAPI.php
public function performAPICallWithJsonResponse($method, $path, array $options = [])
    {
        $response = $this->performAPICall($method, $path, $options);

        if ($response->getStatusCode() === 200) {
            $contents = $response->getBody()->getContents();
            $json     = json_decode($contents, true);
            if ($json === null) {
                throw ParseException::decode();
            }
            // Parse errors first, if any.
            if (array_key_exists('errors', $json)) {
                // Parse error and throw appropriate exception.
                $this->parseErrorSection($json['errors']);
            }
            // Parse links, if any.
            if (array_key_exists('links', $json)) {
                $this->links = $json['links'];
            }
            if (array_key_exists('data', $json) === false) {
                return $json;
            }
            return $json['data'];
        }

        throw new Exception(
            sprintf(
                'Got status code %d from service at path %s',
                $response->getStatusCode(),
                $path
            )
        );
    }
public function performAPICallWithJsonResponse($method, $path, array $options = [])
    {
        $response = $this->performAPICall($method, $path, $options);

        if ($response->getStatusCode() === 200) {
            $contents = $response->getBody()->getContents();
            $json     = json_decode($contents, true);
            if ($json === null) {
                throw ParseException::decode();
            }
            // Parse errors first, if any.
            if (array_key_exists('errors', $json)) {
                // Parse error and throw appropriate exception.
                $this->parseErrorSection($json['errors']);
            }
            // Parse links, if any.
            if (array_key_exists('links', $json)) {
                $this->links = $json['links'];
            }
            if (array_key_exists('data', $json) === false) {
                return $json;
            }
            return $json['data'];
        }

        throw new Exception(
            sprintf(
                'Got status code %d from service at path %s',
                $response->getStatusCode(),
                $path
            )
        );
    }
public function performAPICallWithJsonResponse ( $ method , $ path , array $ options = [ ] ) { $ response = $ this -> performAPICall ( $ method , $ path , $ options ) ; if ( $ response -> getStatusCode ( ) === 200 ) { $ contents = $ response -> getBody ( ) -> getContents ( ) ; $ json = json_decode ( $ contents , true ) ; if ( $ json === null ) { throw ParseException :: decode ( ) ; } // Parse errors first, if any. if ( array_key_exists ( 'errors' , $ json ) ) { // Parse error and throw appropriate exception. $ this -> parseErrorSection ( $ json [ 'errors' ] ) ; } // Parse links, if any. if ( array_key_exists ( 'links' , $ json ) ) { $ this -> links = $ json [ 'links' ] ; } if ( array_key_exists ( 'data' , $ json ) === false ) { return $ json ; } return $ json [ 'data' ] ; } throw new Exception ( sprintf ( 'Got status code %d from service at path %s' , $ response -> getStatusCode ( ) , $ path ) ) ; }
Perform an API call to theTVDb and return a JSON response

@param string $method  HTTP Method (post, getUserData, put, etc.)
@param string $path    Path to the API call
@param array  $options HTTP Client options

@return mixed
@throws ResourceNotFoundException
@throws UnauthorizedException
@throws Exception
Perform an API call to theTVDb and return a JSON response