Properties

$httpClient

$httpClient : \GuzzleHttp\ClientInterface

Type

ClientInterface — HTTP client used to send requests

$handlerStack

$handlerStack : \GuzzleHttp\HandlerStack

Type

HandlerStack

$commandToRequestTransformer

$commandToRequestTransformer : callable

Type

callable

$responseToResultTransformer

$responseToResultTransformer : callable

Type

callable

$config

$config : array

Type

array

$description

$description : \GuzzleHttp\Command\Guzzle\DescriptionInterface

Type

DescriptionInterface — Guzzle service description

Methods

__construct()

__construct(\GuzzleHttp\ClientInterface  $client, \GuzzleHttp\Command\Guzzle\DescriptionInterface  $description, callable  $commandToRequestTransformer = null, callable  $responseToResultTransformer = null, \GuzzleHttp\HandlerStack  $commandHandlerStack = null, array  $config = []) : mixed

The client constructor accepts an associative array of configuration options:

  • defaults: Associative array of default command parameters to add to each command created by the client.
  • validate: Specify if command input is validated (defaults to true). Changing this setting after the client has been created will have no effect.
  • process: Specify if HTTP responses are parsed (defaults to true). Changing this setting after the client has been created will have no effect.
  • response_locations: Associative array of location types mapping to ResponseLocationInterface objects.

Parameters

\GuzzleHttp\ClientInterface $client

HTTP client to use.

\GuzzleHttp\Command\Guzzle\DescriptionInterface $description

Guzzle service description

callable $commandToRequestTransformer
callable $responseToResultTransformer
\GuzzleHttp\HandlerStack $commandHandlerStack
array $config

Configuration options

Returns

mixed —

getHttpClient()

getHttpClient() : \GuzzleHttp\ClientInterface

Get the HTTP client used to send requests for the web service client

Returns

\GuzzleHttp\ClientInterface —

getHandlerStack()

getHandlerStack() : \GuzzleHttp\HandlerStack

Get the HandlerStack which can be used to add middleware to the client.

Returns

\GuzzleHttp\HandlerStack —

getCommand()

getCommand(string  $name, array  $args = []) : \GuzzleHttp\Command\CommandInterface

Returns the command if valid; otherwise an Exception

Parameters

string $name
array $args

Throws

\InvalidArgumentException

Returns

\GuzzleHttp\Command\CommandInterface —

execute()

execute(\GuzzleHttp\Command\CommandInterface  $command) : \GuzzleHttp\Command\ResultInterface

Execute a single command.

Parameters

\GuzzleHttp\Command\CommandInterface $command

Command to execute

Returns

\GuzzleHttp\Command\ResultInterface —

The result of the executed command

executeAsync()

executeAsync(\GuzzleHttp\Command\CommandInterface  $command) : \GuzzleHttp\Promise\PromiseInterface

Execute a single command asynchronously

Parameters

\GuzzleHttp\Command\CommandInterface $command

Command to execute

Returns

\GuzzleHttp\Promise\PromiseInterface —

A Promise that resolves to a Result.

executeAll()

executeAll(mixed  $commands, array  $options = []) : array

Executes multiple commands concurrently using a fixed pool size.

Parameters

mixed $commands

Array or iterator that contains CommandInterface objects to execute with the client.

array $options

Associative array of options to apply.

  • concurrency: (int) Max number of commands to execute concurrently.
  • fulfilled: (callable) Function to invoke when a command completes.
  • rejected: (callable) Function to invoke when a command fails.

Returns

array —

executeAllAsync()

executeAllAsync(mixed  $commands, array  $options = []) : \GuzzleHttp\Promise\PromiseInterface

Executes multiple commands concurrently and asynchronously using a fixed pool size.

Parameters

mixed $commands

Array or iterator that contains CommandInterface objects to execute with the client.

array $options

Associative array of options to apply.

  • concurrency: (int) Max number of commands to execute concurrently.
  • fulfilled: (callable) Function to invoke when a command completes.
  • rejected: (callable) Function to invoke when a command fails.

Returns

\GuzzleHttp\Promise\PromiseInterface —

__call()

__call(string  $name, array  $args) : \GuzzleHttp\Command\ResultInterface|\GuzzleHttp\Promise\PromiseInterface

Creates and executes a command for an operation by name.

Parameters

string $name

Name of the command to execute.

array $args

Arguments to pass to the getCommand method.

Returns

\GuzzleHttp\Command\ResultInterface|\GuzzleHttp\Promise\PromiseInterface —

getDescription()

getDescription() : \GuzzleHttp\Command\Guzzle\DescriptionInterface

Return the description

Returns

\GuzzleHttp\Command\Guzzle\DescriptionInterface —

getConfig()

getConfig(array|string  $option = null) : mixed

Get the config of the client

Parameters

array|string $option

Returns

mixed —

setConfig()

setConfig( $option,  $value) : mixed

Parameters

$option
$value

Returns

mixed —

processConfig()

processConfig(array  $config) : mixed

Prepares the client based on the configuration settings of the client.

Parameters

array $config

Constructor config as an array

Returns

mixed —

createCommandHandler()

createCommandHandler() : callable

Defines the main handler for commands that uses the HTTP client.

Returns

callable —

transformCommandToRequest()

transformCommandToRequest(\GuzzleHttp\Command\CommandInterface  $command) : \Psr\Http\Message\RequestInterface

Transforms a Command object into a Request object.

Parameters

\GuzzleHttp\Command\CommandInterface $command

Returns

\Psr\Http\Message\RequestInterface —

transformResponseToResult()

transformResponseToResult(\Psr\Http\Message\ResponseInterface  $response, \Psr\Http\Message\RequestInterface  $request, \GuzzleHttp\Command\CommandInterface  $command) : \GuzzleHttp\Command\ResultInterface

Transforms a Response object, also using data from the Request object, into a Result object.

Parameters

\Psr\Http\Message\ResponseInterface $response
\Psr\Http\Message\RequestInterface $request
\GuzzleHttp\Command\CommandInterface $command

Returns

\GuzzleHttp\Command\ResultInterface —

getSerializer()

getSerializer(callable|null  $commandToRequestTransformer) : \GuzzleHttp\Command\Guzzle\Serializer

Returns the passed Serializer when set, a new instance otherwise

Parameters

callable|null $commandToRequestTransformer

Returns

\GuzzleHttp\Command\Guzzle\Serializer —

getDeserializer()

getDeserializer(callable|null  $responseToResultTransformer) : \GuzzleHttp\Command\Guzzle\Deserializer

Returns the passed Deserializer when set, a new instance otherwise

Parameters

callable|null $responseToResultTransformer

Returns

\GuzzleHttp\Command\Guzzle\Deserializer —