ResponseSequence
class ResponseSequence
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| 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
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Create a new response sequence.
Push a response to the sequence.
Push a response with the given status code to the sequence.
Push a response with the contents of a file as the body to the sequence.
Push a connection exception 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.
Flush all static state.
Details
in
Macroable at line 28
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 41
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 68
static void
flushMacros()
Flush the existing macros.
Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 103
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 29
__construct(array $responses)
Create a new response sequence.
at line 37
ResponseSequence
push(array|string|null $body = null, int $status = 200, array $headers = [])
Push a response to the sequence.
at line 47
ResponseSequence
pushStatus(int $status, array $headers = [])
Push a response with the given status code to the sequence.
at line 57
ResponseSequence
pushFile(string $filePath, int $status = 200, array $headers = [])
Push a response with the contents of a file as the body to the sequence.
at line 69
ResponseSequence
pushFailedConnection(string|null $message = null)
Push a connection exception to the sequence.
at line 79
ResponseSequence
pushResponse(mixed $response)
Push a response to the sequence.
at line 89
ResponseSequence
whenEmpty(Closure|PromiseInterface $response)
Make the sequence return a default response when it is empty.
at line 100
ResponseSequence
dontFailWhenEmpty()
Make the sequence return a default response when it is empty.
at line 108
bool
isEmpty()
Indicate that this sequence has depleted all of its responses.
at line 118
mixed
__invoke(Request $request)
Get the next response in the sequence.
at line 136
static void
flushState()
Flush all static state.