ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Result.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Data;
22
28interface Result
29{
33 public function isOK(): bool;
34
42 public function value();
43
47 public function isError(): bool;
48
55 public function error();
56
63 public function valueOr($default);
64
72 public function map(callable $f): Result;
73
84 public function then(callable $f): Result;
85
97 public function except(callable $f): Result;
98}
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:29
then(callable $f)
Get a new result from the callable or do nothing if this is an error.
isError()
Get to know if the result is an error.
valueOr($default)
Get the encapsulated value or the supplied default if result is an error.
except(callable $f)
Feed the error into a callable and replace this with the result or do nothing if this is a value.
isOK()
Get to know if the result is ok.
map(callable $f)
Create a new result where the contained value is modified with $f.
value()
Get the encapsulated value.
error()
Get the encapsulated error.