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
Create a new response sequence.
Push a response to the sequence.
Push a response with the given status code to the sequence.
Push response with the contents of a file as the body to the sequence.
Push a response to the sequence.
Make the sequence return a default response when it is empty.
Indicate that this sequence has depleted all of its responses.
Get the next response in the sequence.
Details
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.