ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Result.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 2017 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
3
4namespace ILIAS\Data;
5
11interface Result
12{
18 public function isOK();
19
27 public function value();
28
34 public function isError();
35
42 public function error();
43
50 public function valueOr($default);
51
60 public function map(callable $f);
61
73 public function then(callable $f);
74
87 public function except(callable $f);
88}
$default
Definition: build.php:20
An exception for terminatinating execution or to throw for unit testing.
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:12
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.