W3cubDocs

/Laravel 8

ResponseSequence

class ResponseSequence (View source)

Properties

protected array $responses The responses in the sequence.
protected bool $failWhenEmpty Indicates that invoking this sequence when it is empty should throw an exception.
protected PromiseInterface $emptyResponse The response that should be returned when the sequence is empty.

Methods

void __construct(array $responses)

Create a new response sequence.

$this push(string|array $body = '', int $status = 200, array $headers = [])

Push a response to the sequence.

$this pushStatus(int $status, array $headers = [])

Push a response with the given status code to the sequence.

$this pushFile(string $filePath, int $status = 200, array $headers = [])

Push response with the contents of a file as the body to the sequence.

$this pushResponse(mixed $response)

Push a response to the sequence.

$this whenEmpty(PromiseInterface|Closure $response)

Make the sequence return a default response when it is empty.

$this dontFailWhenEmpty()

Make the sequence return a default response when it is empty.

bool isEmpty()

Indicate that this sequence has depleted all of its responses.

mixed __invoke()

Get the next response in the sequence.

Details

void __construct(array $responses)

Create a new response sequence.

Parameters

array $responses

Return Value

void

$this push(string|array $body = '', int $status = 200, array $headers = [])

Push a response to the sequence.

Parameters

string|array $body
int $status
array $headers

Return Value

$this

$this pushStatus(int $status, array $headers = [])

Push a response with the given status code to the sequence.

Parameters

int $status
array $headers

Return Value

$this

$this pushFile(string $filePath, int $status = 200, array $headers = [])

Push response with the contents of a file as the body to the sequence.

Parameters

string $filePath
int $status
array $headers

Return Value

$this

$this pushResponse(mixed $response)

Push a response to the sequence.

Parameters

mixed $response

Return Value

$this

$this whenEmpty(PromiseInterface|Closure $response)

Make the sequence return a default response when it is empty.

Parameters

PromiseInterface|Closure $response

Return Value

$this

$this dontFailWhenEmpty()

Make the sequence return a default response when it is empty.

Return Value

$this

bool isEmpty()

Indicate that this sequence has depleted all of its responses.

Return Value

bool

mixed __invoke()

Get the next response in the sequence.

Return Value

mixed

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/8.x/Illuminate/Http/Client/ResponseSequence.html