CallSilencer
class CallSilencer implements CallSilencerInterface
Implementation for calling closure in error-silenced environment.
Methods
Sets the closure used to test validity of return value. When called, this closure is provided the return value of the invoked closure, as well the last raised error array (as first and second parameters).
Invoke closure in silenced environment.
Returns true if a non-null value was returned from invoked closure.
Get the return value invoked closure.
Returns type hinted value from validation closure.
Returns true if the invoked closure return value is true (strict check).
Returns true if the invoked closure return value is false (strict check).
Return true if an error was raised by invoking closure.
Returns the error raised by invoking closure.
Details
at line line 50
static
CallSilencerInterface
create(
Closure $closure = null,
Closure $validator = null)
Static method to create class instance with optional closure and validator parameters.
at line line 72
$this
setClosure(
Closure $closure)
Sets the closure to invoke.
at line line 87
$this
setValidator(
Closure $validator)
Sets the closure used to test validity of return value. When called, this closure is provided the return value of the invoked closure, as well the last raised error array (as first and second parameters).
at line line 103
$this
invoke(
bool $restore = true)
Invoke closure in silenced environment.
at line line 135
bool
hasResult()
Returns true if a non-null value was returned from invoked closure.
at line line 145
mixed
getResult()
Get the return value invoked closure.
at line line 157
bool
isResultValid()
Returns type hinted value from validation closure.
at line line 171
bool
isResultTrue()
Returns true if the invoked closure return value is true (strict check).
at line line 181
bool
isResultFalse()
Returns true if the invoked closure return value is false (strict check).
at line line 191
bool
hasError()
Return true if an error was raised by invoking closure.
at line line 203
string[]|string
getError(
string|null $index = self::ERROR_MESSAGE)
Returns the error raised by invoking closure.