34 if (!is_callable(
$error)) {
35 $this->error =
function () use (
$error) {
48 final public function check($value)
62 return call_user_func($this->is_ok, $value);
87 if ($problem !== null) {
88 $error = $this->data_factory->error($problem);
100 $clone = clone $this;
112 return call_user_func($this->error, $value);
value()
Get the encapsulated value.
isError()
Get to know if the result is an error.
check($value)
Checks the provided value.Should not throw if accepts($value).
A constraint encodes some resrtictions on values.
A result encapsulates a value or an error and simplifies the handling of those.
accepts($value)
Tells if the provided value complies.bool
getErrorMessage($value)
Get the problem message.
problemWith($value)
Tells what the problem with the provided value is.Should return null if accepts($value).string|null
withProblemBuilder(callable $builder)
Get a constraint like this one with a builder for a custom error message.problemWith() must return an...
restrict(Result $result)
Restricts a Result.Must do nothing with the result if $result->isError(). Must replace the result wit...
__construct(callable $is_ok, $error, Data\Factory $data_factory)