src/Communibase/Connector.php
private function call($method, array $arguments)
    {
        try {

            /**
             * Due to GuzzleHttp not passing a default host header given to the client to _every_ request made by the
             * client we manually check to see if we need to add a hostheader to requests.
             * When the issue is resolved the foreach can be removed (as the function might even?)
             *
             * @see https://github.com/guzzle/guzzle/issues/1297
             */
            if (isset($this->extraHeaders['host'])) {
                $arguments[1]['headers']['Host'] = $this->extraHeaders['host'];
            }

            if ($this->logger) {
                $this->logger->startQuery($method . ' ' . reset($arguments), $arguments);
            }

            $response = call_user_func_array([$this->getClient(), $method], $arguments);

            if ($this->logger) {
                $this->logger->stopQuery();
            }

            return $response;

            // try to catch the Guzzle client exception (404's, validation errors etc) and wrap them into a CB exception
        } catch (ClientException $e) {

            $response = $e->getResponse();
            $response = json_decode($response === null ? '' : $response->getBody(), true);

            throw new Exception(
                $response['message'],
                $response['code'],
                $e,
                (($_ =& $response['errors']) ?: [])
            );

        } catch (ConnectException $e) {

            throw new Exception('Can not connect', 500, $e, []);

        }
    }
private function call($method, array $arguments)
    {
        try {

            /**
             * Due to GuzzleHttp not passing a default host header given to the client to _every_ request made by the
             * client we manually check to see if we need to add a hostheader to requests.
             * When the issue is resolved the foreach can be removed (as the function might even?)
             *
             * @see https://github.com/guzzle/guzzle/issues/1297
             */
            if (isset($this->extraHeaders['host'])) {
                $arguments[1]['headers']['Host'] = $this->extraHeaders['host'];
            }

            if ($this->logger) {
                $this->logger->startQuery($method . ' ' . reset($arguments), $arguments);
            }

            $response = call_user_func_array([$this->getClient(), $method], $arguments);

            if ($this->logger) {
                $this->logger->stopQuery();
            }

            return $response;

            // try to catch the Guzzle client exception (404's, validation errors etc) and wrap them into a CB exception
        } catch (ClientException $e) {

            $response = $e->getResponse();
            $response = json_decode($response === null ? '' : $response->getBody(), true);

            throw new Exception(
                $response['message'],
                $response['code'],
                $e,
                (($_ =& $response['errors']) ?: [])
            );

        } catch (ConnectException $e) {

            throw new Exception('Can not connect', 500, $e, []);

        }
    }
private function call ( $ method , array $ arguments ) { try { /**
             * Due to GuzzleHttp not passing a default host header given to the client to _every_ request made by the
             * client we manually check to see if we need to add a hostheader to requests.
             * When the issue is resolved the foreach can be removed (as the function might even?)
             *
             * @see https://github.com/guzzle/guzzle/issues/1297
             */ if ( isset ( $ this -> extraHeaders [ 'host' ] ) ) { $ arguments [ 1 ] [ 'headers' ] [ 'Host' ] = $ this -> extraHeaders [ 'host' ] ; } if ( $ this -> logger ) { $ this -> logger -> startQuery ( $ method . ' ' . reset ( $ arguments ) , $ arguments ) ; } $ response = call_user_func_array ( [ $ this -> getClient ( ) , $ method ] , $ arguments ) ; if ( $ this -> logger ) { $ this -> logger -> stopQuery ( ) ; } return $ response ; // try to catch the Guzzle client exception (404's, validation errors etc) and wrap them into a CB exception } catch ( ClientException $ e ) { $ response = $ e -> getResponse ( ) ; $ response = json_decode ( $ response === null ? '' : $ response -> getBody ( ) , true ) ; throw new Exception ( $ response [ 'message' ] , $ response [ 'code' ] , $ e , ( ( $ _ = & $ response [ 'errors' ] ) ? : [ ] ) ) ; } catch ( ConnectException $ e ) { throw new Exception ( 'Can not connect' , 500 , $ e , [ ] ) ; } }
Perform the actual call to Communibase

@param string $method
@param array $arguments

@return \Psr\Http\Message\ResponseInterface

@throws Exception
Perform the actual call to Communibase