protected function checkResponseFormat(Response $response)
    {
        set_error_handler(function() { /* ignore errors */ });
        $arr = json_decode($response->getBody(), true, 512, 1);
        restore_error_handler();

        if (isset($arr['error'])) {
            throw new DiffbotException('Diffbot returned error ' . $arr['errorCode'] . ': ' . $arr['error']);
        }

        $required = [
            'objects' => 'Objects property missing - cannot extract entity values',
            'request' => 'Request property not found in response!'
        ];

        foreach ($required as $k=>$v) {
            if (!isset($arr[$k])) {
                throw new DiffbotException($v);
            }
        }

    }
protected function checkResponseFormat(Response $response)
    {
        set_error_handler(function() { /* ignore errors */ });
        $arr = json_decode($response->getBody(), true, 512, 1);
        restore_error_handler();

        if (isset($arr['error'])) {
            throw new DiffbotException('Diffbot returned error ' . $arr['errorCode'] . ': ' . $arr['error']);
        }

        $required = [
            'objects' => 'Objects property missing - cannot extract entity values',
            'request' => 'Request property not found in response!'
        ];

        foreach ($required as $k=>$v) {
            if (!isset($arr[$k])) {
                throw new DiffbotException($v);
            }
        }

    }
protected function checkResponseFormat ( Response $ response ) { set_error_handler ( function ( ) { /* ignore errors */ } ) ; $ arr = json_decode ( $ response -> getBody ( ) , true , 512 , 1 ) ; restore_error_handler ( ) ; if ( isset ( $ arr [ 'error' ] ) ) { throw new DiffbotException ( 'Diffbot returned error ' . $ arr [ 'errorCode' ] . ': ' . $ arr [ 'error' ] ) ; } $ required = [ 'objects' => 'Objects property missing - cannot extract entity values' , 'request' => 'Request property not found in response!' ] ; foreach ( $ required as $ k => $ v ) { if ( ! isset ( $ arr [ $ k ] ) ) { throw new DiffbotException ( $ v ) ; } } }
Makes sure the Diffbot response has all the fields it needs to work properly

@todo: remove error avoidance when issue 12 is fixed: https://github.com/Swader/diffbot-php-client/issues/12
@param Response $response
@throws DiffbotException
Makes sure the Diffbot response has all the fields it needs to work properly