ILIAS
trunk Revision v11.0_alpha-1811-gd2d5443e411
|
A result encapsulates a value or an error and simplifies the handling of those. More...
Public Member Functions | |
isOK () | |
Get to know if the result is ok. More... | |
value () | |
Get the encapsulated value. More... | |
isError () | |
Get to know if the result is an error. More... | |
error () | |
Get the encapsulated error. More... | |
valueOr ($default) | |
Get the encapsulated value or the supplied default if result is an error. More... | |
map (callable $f) | |
Create a new result where the contained value is modified with $f. More... | |
then (callable $f) | |
Get a new result from the callable or do nothing if this is an error. More... | |
except (callable $f) | |
Feed the error into a callable and replace this with the result or do nothing if this is a value. More... | |
A result encapsulates a value or an error and simplifies the handling of those.
To be implemented as immutable object.
Definition at line 28 of file Result.php.
ILIAS\Data\Result::error | ( | ) |
Get the encapsulated error.
Implemented in ILIAS\Data\Result\Error, and ILIAS\Data\Result\Ok.
Referenced by ilScormAiccImporter\importXmlRepresentation(), and ilLegalDocumentsAdministrationGUI\returnWithResult().
ILIAS\Data\Result::except | ( | callable | $f | ) |
Feed the error into a callable and replace this with the result or do nothing if this is a value.
If null is returned from $f, the error in the result is not touched.
Does nothing if !isError.
callable | $f | string| -> Result|null |
Implemented in ILIAS\Data\Result\Ok, and ILIAS\Data\Result\Error.
Referenced by ilObjTestAccess\findMatch().
ILIAS\Data\Result::isError | ( | ) |
Get to know if the result is an error.
Implemented in ILIAS\Data\Result\Error, and ILIAS\Data\Result\Ok.
Referenced by ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint\applyTo().
ILIAS\Data\Result::isOK | ( | ) |
Get to know if the result is ok.
Implemented in ILIAS\Data\Result\Error, and ILIAS\Data\Result\Ok.
Referenced by ILIAS\Test\Presentation\TestScreenGUI\evaluateLauncherModalForm(), ILIAS\UI\Implementation\Component\Input\Field\SwitchableGroup\getValue(), ILIAS\Tests\Refinery\Parser\ABNF\TransformTest\testFailedToParse(), ILIAS\Tests\Refinery\Parser\ABNF\TransformTest\testFailedToTransform(), and ILIAS\UI\examples\Launcher\Inline\with_fields().
ILIAS\Data\Result::map | ( | callable | $f | ) |
Create a new result where the contained value is modified with $f.
Does nothing if !isOK.
callable | $f | mixed -> mixed |
Implemented in ILIAS\Data\Result\Error, and ILIAS\Data\Result\Ok.
Referenced by ILIAS\Tests\Refinery\Parser\ABNF\TransformTest\testAs().
ILIAS\Data\Result::then | ( | callable | $f | ) |
Get a new result from the callable or do nothing if this is an error.
If null is returned from $f, the result is not touched.
Does nothing if !isOK. This is monadic bind.
callable | $f | mixed -> Result|null |
Implemented in ILIAS\Data\Result\Error, and ILIAS\Data\Result\Ok.
Referenced by ILIAS\Refinery\applyTo(), ILIAS\Refinery\Parser\ABNF\Brick\consume(), ILIAS\Refinery\Parser\ABNF\Transform\from(), ilInitialisation\getClientIdTransformation(), ILIAS\Refinery\Parser\ABNF\Primitives\seq(), and ILIAS\LegalDocuments\Provide\ProvideDocument\validateAgainst().
ILIAS\Data\Result::value | ( | ) |
Get the encapsulated value.
Implemented in ILIAS\Data\Result\Error, and ILIAS\Data\Result\Ok.
Referenced by ILIAS\Refinery\String\SplitString\applyTo(), ILIAS\UI\Implementation\Component\Input\Container\Container\AddLabels\applyTo(), ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint\applyTo(), ILIAS\Test\Presentation\TestScreenGUI\evaluateLauncherModalForm(), ILIAS\UI\Implementation\Component\Input\Field\SwitchableGroup\getValue(), ILIAS\Tests\Refinery\Parser\ABNF\TransformTest\testFailedToParse(), ILIAS\Tests\Refinery\Parser\ABNF\TransformTest\testFailedToTransform(), ILIAS\Tests\Refinery\Parser\ABNF\TransformTest\testTo(), GroupInputTest\testWithoutChildren(), and ILIAS\UI\examples\Launcher\Inline\with_fields().
ILIAS\Data\Result::valueOr | ( | $default | ) |
Get the encapsulated value or the supplied default if result is an error.
mixed | $default |
Implemented in ILIAS\Data\Result\Error, and ILIAS\Data\Result\Ok.