ILIAS  release_8 Revision v8.23
ILIAS\Refinery\Transformation Interface Reference

A transformation is a function from one datatype to another. More...

+ Inheritance diagram for ILIAS\Refinery\Transformation:
+ Collaboration diagram for ILIAS\Refinery\Transformation:

Public Member Functions

 transform ($from)
 Perform the transformation. More...
 
 applyTo (Result $result)
 Perform the transformation and reify possible failures. More...
 
 __invoke ($from)
 Transformations should be callable. More...
 

Detailed Description

A transformation is a function from one datatype to another.

It MUST NOT perform any sideeffects, i.e. it must be morally impossible to observe how often the transformation was actually performed. It MUST NOT touch the provided value, i.e. it is allowed to create new values but not to modify existing values. This would be an observable sideeffect.

Definition at line 34 of file Transformation.php.

Member Function Documentation

◆ __invoke()

ILIAS\Refinery\Transformation::__invoke (   $from)

Transformations should be callable.

This MUST do the same as transform.

Parameters
mixed$from
Returns
mixed
Exceptions
InvalidArgumentExceptionif the argument could not be transformed

Implemented in ILIAS\Refinery\To\Transformation\NewObjectTransformation.

◆ applyTo()

ILIAS\Refinery\Transformation::applyTo ( Result  $result)

Perform the transformation and reify possible failures.

If $data->isError(), the method MUST do nothing. It MUST transform the value in $data like it would transform $data provided to transform. It must reify every exception thrown in this process by returning a Result that isError() and contains the exception that happened.

If you simply need to implement a transformation you most probably want to implement transform and derive this via the trait DeriveTransformationInterface.

If you simply want to call the transformation, you most probably want to use transform, since it simply throws exceptions that occurred while doing the transformation.

If you are implementing some entity that performs processing of input data at some boundary, the reification of exceptions might help you to write cleaner code.

Implemented in ILIAS\Refinery\Custom\Constraint, ILIAS\Refinery\Constraint, ILIAS\Refinery\Container\AddLabels, and ILIAS\Refinery\String\SplitString.

Referenced by ILIAS\UI\Implementation\Component\Input\Input\setAdditionalTransformation().

+ Here is the caller graph for this function:

◆ transform()

ILIAS\Refinery\Transformation::transform (   $from)

Perform the transformation.

Please use this for transformations. It's more performant than calling invoke.

Parameters
mixed$from
Returns
mixed
Exceptions
InvalidArgumentExceptionif the argument could not be transformed

Implemented in ILIAS\Refinery\String\CaseOfLabel, ILIAS\Refinery\String\Transformation\LevenshteinTransformation, ILIAS\Refinery\To\Transformation\RecordTransformation, ILIAS\Refinery\KindlyTo\Transformation\RecordTransformation, ILIAS\Refinery\ByTrying, ILIAS\Refinery\To\Transformation\TupleTransformation, ILIAS\Refinery\In\Parallel, ILIAS\Refinery\In\Series, ILIAS\Refinery\KindlyTo\Transformation\TupleTransformation, ILIAS\Refinery\Container\AddLabels, ILIAS\Refinery\String\EstimatedReadingTime, ILIAS\Refinery\DateTime\ChangeTimezone, ILIAS\Refinery\To\Transformation\NewMethodTransformation, ILIAS\Refinery\String\SplitString, ILIAS\Refinery\Container\MapValues, ILIAS\Refinery\Random\Transformation\ShuffleTransformation, ILIAS\Refinery\Custom\Transformation, ILIAS\Refinery\To\Transformation\DictionaryTransformation, ILIAS\Refinery\To\Transformation\DateTimeTransformation, ILIAS\Refinery\To\Transformation\ListTransformation, ILIAS\Refinery\KindlyTo\Transformation\DateTimeTransformation, ILIAS\Refinery\KindlyTo\Transformation\DictionaryTransformation, ILIAS\Refinery\String\MakeClickable, ILIAS\Refinery\To\Transformation\NewObjectTransformation, ILIAS\Refinery\KindlyTo\Transformation\BooleanTransformation, ILIAS\Refinery\KindlyTo\Transformation\ListTransformation, ILIAS\Refinery\KindlyTo\Transformation\StringTransformation, ILIAS\Refinery\String\StripTags, ILIAS\Refinery\ConstantTransformation, ILIAS\Refinery\KindlyTo\Transformation\FloatTransformation, ILIAS\Refinery\To\Transformation\BooleanTransformation, ILIAS\Refinery\To\Transformation\FloatTransformation, ILIAS\Refinery\To\Transformation\IntegerTransformation, ILIAS\Refinery\To\Transformation\StringTransformation, ILIAS\Refinery\KindlyTo\Transformation\IntegerTransformation, ILIAS\Refinery\KindlyTo\Transformation\NullTransformation, and ILIAS\Refinery\IdentityTransformation.

Referenced by assClozeGap\getItems(), and ILIAS\HTTP\Wrapper\ArrayBasedRequestWrapper\retrieve().

+ Here is the caller graph for this function:

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