ILIAS
trunk Revision v11.0_alpha-2638-g80c1d007f79
|
A transformation is a function from one datatype to another. More...
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... | |
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.
ILIAS\Refinery\Transformation::__invoke | ( | $from | ) |
Transformations should be callable.
This MUST do the same as transform.
mixed | $from |
InvalidArgumentException | if the argument could not be transformed |
Implemented in ILIAS\Refinery\To\Transformation\NewObjectTransformation.
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\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint, and ILIAS\Refinery\Constraint.
Referenced by ILIAS\UI\Implementation\Component\Input\Input\setAdditionalTransformation(), and ILIAS\Refinery\Parser\ABNF\Transform\to().
ILIAS\Refinery\Transformation::transform | ( | $from | ) |
Perform the transformation.
Please use this for transformations. It's more performant than calling invoke.
mixed | $from |
InvalidArgumentException | if the argument could not be transformed |
Implemented in ILIAS\Refinery\String\CaseOfLabel, ILIAS\Refinery\String\Transformation\LevenshteinTransformation, ILIAS\Refinery\To\Transformation\RecordTransformation, ILIAS\Refinery\ByTrying, ILIAS\Refinery\KindlyTo\Transformation\RecordTransformation, ILIAS\Refinery\To\Transformation\TupleTransformation, ILIAS\Refinery\In\Parallel, ILIAS\Refinery\In\Series, ILIAS\Refinery\KindlyTo\Transformation\TupleTransformation, ILIAS\UI\Implementation\Component\Input\Container\Container\AddLabels, ILIAS\Refinery\String\EstimatedReadingTime, DateTime\ChangeTimezone, ILIAS\Refinery\To\Transformation\NewMethodTransformation, ILIAS\Refinery\String\SplitString, ILIAS\Refinery\Random\Transformation\ShuffleTransformation, ILIAS\UI\Implementation\Component\Input\Container\Container\MapValues, ILIAS\Refinery\String\Encoding\Encoding, ILIAS\Refinery\To\Transformation\DictionaryTransformation, ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Transformation, ILIAS\Refinery\To\Transformation\DateTimeTransformation, ILIAS\Refinery\To\Transformation\ListTransformation, ILIAS\Refinery\KindlyTo\Transformation\DateTimeTransformation, ILIAS\Refinery\KindlyTo\Transformation\DictionaryTransformation, ILIAS\Refinery\To\Transformation\NewObjectTransformation, ILIAS\Refinery\Encode\Transformation\HTMLAttributeValue, ILIAS\Refinery\Encode\Transformation\HTMLSpecialCharsAsEntities, ILIAS\Refinery\KindlyTo\Transformation\BooleanTransformation, ILIAS\Refinery\KindlyTo\Transformation\ListTransformation, ILIAS\Refinery\KindlyTo\Transformation\StringTransformation, ILIAS\Refinery\String\MakeClickable, ILIAS\Refinery\Encode\Transformation\URL, ILIAS\Refinery\Encode\Transformation\Json, 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\Data\URI\StringTransformation, ILIAS\Refinery\KindlyTo\Transformation\NullTransformation, and ILIAS\Refinery\IdentityTransformation.
Referenced by assClozeGap\getItems(), and ILIAS\MetaData\Vocabularies\Controlled\Database\Wrapper\ArrayBasedRequestWrapper\retrieve().