CallSilencerInterface
interface CallSilencerInterface
Interface for calling closure in error-silenced environment.
Constants
ERROR_ARRAY |
Optional constant parameter for {see getError()} to get error as original array. |
ERROR_MESSAGE |
Optional constant parameter for {see getError()} to get error message. |
ERROR_TYPE |
Optional constant parameter for {see getError()} to get error type. |
ERROR_FILE |
Optional constant parameter for {see getError()} to get error file. |
ERROR_LINE |
Optional constant parameter for {see getError()} to get error line. |
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 52
static
CallSilencerInterface
create(
Closure $closure = null,
Closure $validator = null)
Static method to create class instance with optional closure and validator parameters.
at line line 61
$this
setClosure(
Closure $invokable)
Sets the closure to invoke.
at line line 71
$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 80
$this
invoke(
bool $restore = true)
Invoke closure in silenced environment.
at line line 87
bool
hasResult()
Returns true if a non-null value was returned from invoked closure.
at line line 94
mixed
getResult()
Get the return value invoked closure.
at line line 101
bool
isResultValid()
Returns type hinted value from validation closure.
at line line 108
bool
isResultTrue()
Returns true if the invoked closure return value is true (strict check).
at line line 115
bool
isResultFalse()
Returns true if the invoked closure return value is false (strict check).
at line line 122
bool
hasError()
Return true if an error was raised by invoking closure.
at line line 131
string[]|string
getError(
string|null $index = self::ERROR_MESSAGE)
Returns the error raised by invoking closure.