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 Closure|PromiseInterface|null | $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 30
__construct(array $responses)
Create a new response sequence.
at line 40
ResponseSequence
push(mixed $body = null, int $status = 200, array $headers = [])
Push a response to the sequence.
at line 50
ResponseSequence
pushStatus(int $status, array $headers = [])
Push a response with the given status code to the sequence.
at line 60
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 72
ResponseSequence
pushFailedConnection(string|null $message = null)
Push a connection exception to the sequence.
at line 82
ResponseSequence
pushResponse(mixed $response)
Push a response to the sequence.
at line 92
ResponseSequence
whenEmpty(Closure|PromiseInterface $response)
Make the sequence return a default response when it is empty.
at line 103
ResponseSequence
dontFailWhenEmpty()
Make the sequence return a default response when it is empty.
at line 111
bool
isEmpty()
Indicate that this sequence has depleted all of its responses.
at line 121
mixed
__invoke(Request $request)
Get the next response in the sequence.
at line 139
static void
flushState()
Flush all static state.