ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Data\Result Interface Reference

A result encapsulates a value or an error and simplifies the handling of those. More...

+ Inheritance diagram for ILIAS\Data\Result:
+ Collaboration diagram for ILIAS\Data\Result:

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...
 

Detailed Description

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.

Member Function Documentation

◆ error()

ILIAS\Data\Result::error ( )

Get the encapsulated error.

Returns
|string
Exceptions

Implemented in ILIAS\Data\Result\Error, and ILIAS\Data\Result\Ok.

Referenced by ilScormAiccImporter\importXmlRepresentation(), and ilLegalDocumentsAdministrationGUI\returnWithResult().

+ Here is the caller graph for this function:

◆ except()

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.

Parameters
callable$fstring| -> Result|null
Exceptions

Implemented in ILIAS\Data\Result\Ok, and ILIAS\Data\Result\Error.

Referenced by ilObjTestAccess\findMatch().

+ Here is the caller graph for this function:

◆ isError()

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().

+ Here is the caller graph for this function:

◆ isOK()

◆ map()

ILIAS\Data\Result::map ( callable  $f)

Create a new result where the contained value is modified with $f.

Does nothing if !isOK.

Parameters
callable$fmixed -> mixed

Implemented in ILIAS\Data\Result\Error, and ILIAS\Data\Result\Ok.

Referenced by ILIAS\Tests\Refinery\Parser\ABNF\TransformTest\testAs().

+ Here is the caller graph for this function:

◆ then()

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.

Parameters
callable$fmixed -> Result|null
Exceptions

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().

+ Here is the caller graph for this function:

◆ value()

◆ valueOr()

ILIAS\Data\Result::valueOr (   $default)

Get the encapsulated value or the supplied default if result is an error.

Parameters
mixed$default
Returns
mixed

Implemented in ILIAS\Data\Result\Error, and ILIAS\Data\Result\Ok.


The documentation for this interface was generated from the following file: