Copied!

Creates a composed Guzzle handler function by stacking middlewares on top of
an HTTP handler function.

  • final
CloneableInstantiable
Methods
public __construct(?callable $handler = NULL)
 
  • param callable|null $handler Underlying HTTP handler.
public __invoke(Psr\Http\Message\RequestInterface $request, array $options)
 

Invokes the handler stack as a composed handler

  • return \ResponseInterface|\PromiseInterface
public __toString() : string
 

Dumps a string representation of the stack.

  • return string
public after(string $findName, callable $middleware, string $withName = '') : void
 

Add a middleware after another middleware by name.

  • param string $findName Middleware to find
  • param callable callable $middleware Middleware function
  • param string $withName Name to register for this middleware.
public before(string $findName, callable $middleware, string $withName = '') : void
 

Add a middleware before another middleware by name.

  • param string $findName Middleware to find
  • param callable callable $middleware Middleware function
  • param string $withName Name to register for this middleware.
public static create(?callable $handler = NULL) : self
 

Creates a default handler stack that can be used by clients.

The returned handler will wrap the provided handler or use the most
appropriate default handler for your system. The returned HandlerStack has
support for cookies, redirects, HTTP error exceptions, and preparing a body
before sending.

The returned handler stack can be passed to a client in the "handler"
option.

  • param callable|null $handler HTTP handler function to use with the stack. If no
    handler is provided, the best handler for your
    system will be utilized.
public hasHandler() : bool
 

Returns true if the builder has a handler.

public push(callable $middleware, string $name = '') : void
 

Push a middleware to the top of the stack.

  • param callable callable $middleware Middleware function
  • param string $name Name to register for this middleware.
public remove( $remove) : void
 

Remove a middleware by instance or name from the stack.

  • param callable|string $remove Middleware to remove by instance or name.
public resolve() : callable
 

Compose the middleware and handler into a single callable function.

  • return callable PromiseInterface
public setHandler(callable $handler) : void
 

Set the HTTP handler that actually returns a promise.

  • param callable PromiseInterface $handler Accepts a request and array of options and
    returns a Promise.
public unshift(callable $middleware, ?string $name = NULL) : void
 

Unshift a middleware to the bottom of the stack.

  • param callable callable $middleware Middleware function
  • param string $name Name to register for this middleware.
Properties
private $cached = NULL
 
  • var callable|null
private $handler = NULL
 
  • var callable|null
private $stack = []
 
  • var array{: callable, : string|null}[]
Methods
private debugCallable( $fn) : string
 

Provides a debug string for a given callable.

  • param callable|string $fn Function to write as a string.
private findByName(string $name) : int
private splice(string $findName, string $withName, callable $middleware, bool $before) : void
 

Splices a function into the middleware list at a specific position.

Methods
public static create(?callable $handler = NULL) : self
 

Creates a default handler stack that can be used by clients.

The returned handler will wrap the provided handler or use the most
appropriate default handler for your system. The returned HandlerStack has
support for cookies, redirects, HTTP error exceptions, and preparing a body
before sending.

The returned handler stack can be passed to a client in the "handler"
option.

  • param callable|null $handler HTTP handler function to use with the stack. If no
    handler is provided, the best handler for your
    system will be utilized.
© 2023 Bruce Wells
Search Namespaces \ Classes
Configuration