ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Refinery Namespace Reference

Namespaces

namespace  Container
 
namespace  Custom
 
namespace  DateTime
 
namespace  Encode
 
namespace  In
 
namespace  Integer
 
namespace  KindlyTo
 
namespace  Logical
 
namespace  Numeric
 
namespace  Password
 
namespace  Random
 
namespace  String
 
namespace  To
 
namespace  URI
 

Data Structures

class  ByTrying
 
class  ConstantTransformation
 
interface  Constraint
 A constraint encodes some resrtictions on values. More...
 
class  ConstraintViolationException
 
class  Factory
 
class  FactoryFactory
 This Javaism is required to solve the problem that we do not have proper \ILIAS\Language\Language during the setup. More...
 
class  IdentityTransformation
 
class  IsExecutableTransformation
 Validates that the given string is a valid and executable file path. More...
 
class  IsNull
 
class  KeyValueAccess
 
interface  Transformation
 A transformation is a function from one datatype to another. More...
 

Functions

 applyTo (Result $result)
 @inheritDoc More...
 
 __invoke ($from)
 @inheritDoc More...
 
 transform ($from)
 
 check ($value)
 
 problemWith ($value)
 
 withProblemBuilder (callable $builder)
 
 getErrorMessage ($value)
 
 getLngClosure ()
 Get the closure to be passed to the error-function that does i18n and sprintf. More...
 

Function Documentation

◆ __invoke()

ILIAS\Refinery\__invoke (   $from)

@inheritDoc

Definition at line 33 of file DeriveInvokeFromTransform.php.

34 {
35 return $this->transform($from);
36 }

References ILIAS\Refinery\transform().

Referenced by ilInitialisation\getClientIdTransformation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyTo()

ILIAS\Refinery\applyTo ( Result  $result)

@inheritDoc

Definition at line 38 of file DeriveApplyToFromTransform.php.

38 : Result
39 {
40 return $result->then(function ($value): Result {
41 try {
42 return new Ok($this->transform($value));
43 } catch (Exception $exception) {
44 return new Error($exception);
45 }
46 });
47 }
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Ok.php:31
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:29
then(callable $f)
Get a new result from the callable or do nothing if this is an error.

References ILIAS\Data\Result\then(), and ILIAS\Refinery\transform().

Referenced by ilInitialisation\getClientIdTransformation(), ILIAS\Tests\Refinery\IdentityTransformationTest\testApplyToError(), and ILIAS\Tests\Refinery\IdentityTransformationTest\testApplyToOk().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check()

ILIAS\Refinery\check (   $value)

Definition at line 42 of file DeriveTransformWithProblem.php.

43 {
44 if (!$this->accepts($value)) {
45 throw new UnexpectedValueException($this->getErrorMessage($value));
46 }
47 }
getErrorMessage($value)

References ILIAS\Refinery\getErrorMessage().

Referenced by ILIAS\ResourceStorage\Policy\FileNamePolicyTest\getFileNamePolicy(), and ILIAS\Refinery\transform().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getErrorMessage()

ILIAS\Refinery\getErrorMessage (   $value)
final

Definition at line 39 of file ProblemBuilder.php.

39 : string
40 {
41 $error = $this->getError();
42 if (!is_callable($error)) {
43 return $error;
44 }
45 $lng_closure = $this->getLngClosure();
46 return $error($lng_closure, $value);
47 }
getError()
getLngClosure()
Get the closure to be passed to the error-function that does i18n and sprintf.

References ILIAS\$error, getError(), and ILIAS\Refinery\getLngClosure().

Referenced by assTextQuestionGUI\addSuggestedSolution(), ILIAS\Refinery\Custom\Constraint\check(), ILIAS\Refinery\check(), ILIAS\Refinery\To\Transformation\BooleanTransformation\check(), ILIAS\Refinery\To\Transformation\DateTimeTransformation\check(), ILIAS\Refinery\To\Transformation\DictionaryTransformation\check(), ILIAS\Refinery\To\Transformation\FloatTransformation\check(), ILIAS\Refinery\To\Transformation\IntegerTransformation\check(), ILIAS\Refinery\To\Transformation\ListTransformation\check(), ILIAS\Refinery\To\Transformation\RecordTransformation\check(), ILIAS\Refinery\To\Transformation\StringTransformation\check(), ILIAS\Refinery\To\Transformation\TupleTransformation\check(), ILIAS\Refinery\Custom\Constraint\problemWith(), ILIAS\Refinery\problemWith(), ILIAS\Refinery\To\Transformation\BooleanTransformation\problemWith(), ILIAS\Refinery\To\Transformation\DateTimeTransformation\problemWith(), ILIAS\Refinery\To\Transformation\DictionaryTransformation\problemWith(), ILIAS\Refinery\To\Transformation\FloatTransformation\problemWith(), ILIAS\Refinery\To\Transformation\IntegerTransformation\problemWith(), ILIAS\Refinery\To\Transformation\ListTransformation\problemWith(), ILIAS\Refinery\To\Transformation\RecordTransformation\problemWith(), ILIAS\Refinery\To\Transformation\StringTransformation\problemWith(), ILIAS\Refinery\To\Transformation\TupleTransformation\problemWith(), and ILIAS\Refinery\ByTrying\transform().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLngClosure()

ILIAS\Refinery\getLngClosure ( )
finalprotected

Get the closure to be passed to the error-function that does i18n and sprintf.

Definition at line 52 of file ProblemBuilder.php.

52 : Closure
53 {
54 return function (string $lang_var, ...$args): string {
55 $error = $this->lng->txt($lang_var);
56
57 if ($args === []) {
58 return $error;
59 }
60
61 return sprintf($error, ...array_map(function ($v) {
62 if (is_array($v)) {
63 return "array";
64 } elseif (is_null($v)) {
65 return "null";
66 } elseif (is_object($v) && !method_exists($v, "__toString")) {
67 return get_class($v);
68 }
69 return $v;
70 }, $args));
71 };
72 }

References ILIAS\$error, and ILIAS\Repository\lng().

Referenced by ILIAS\Refinery\getErrorMessage(), and CustomTest\setUp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ problemWith()

ILIAS\Refinery\problemWith (   $value)

Definition at line 49 of file DeriveTransformWithProblem.php.

49 : ?string
50 {
51 if (!$this->accepts($value)) {
52 return $this->getErrorMessage($value);
53 }
54
55 return null;
56 }

References ILIAS\Refinery\getErrorMessage().

+ Here is the call graph for this function:

◆ transform()

ILIAS\Refinery\transform (   $from)

Definition at line 36 of file DeriveTransformWithProblem.php.

37 {
38 $this->check($from);
39 return $from;
40 }

References ILIAS\Refinery\check().

Referenced by ILIAS\Refinery\Parser\ABNF\Brick\__construct(), ILIAS\Refinery\__invoke(), ILIAS\Refinery\applyTo(), ilObjTestGUI\buildInputPoolSelection(), ilMailFormGUI\editAttachments(), ilMailSearchObjectMembershipsTableGUI\fillRow(), ilInitialisation\getClientIdTransformation(), ILIAS\Refinery\Parser\ABNF\Brick\namesFromKeys(), ILIAS\Test\Questions\Presentation\QuestionsTableQuery\retrieveStringOrNull(), ilMailCronOrphanedMails\saveCustomSettings(), ilMailFormGUI\saveMailBeforeSearch(), ilMailFormGUI\searchUsers(), ILIAS\User\Profile\PersonalProfileGUI\showPublicProfileFields(), ILIAS\Tests\Refinery\Encode\Transformation\HTMLAttributeValueTest\testInvalidEncoding(), ILIAS\Tests\Refinery\Encode\Transformation\HTMLSpecialCharsAsEntitiesTest\testInvalidEncoding(), ILIAS\Tests\Refinery\Encode\Transformation\JsonTest\testInvalidEncoding(), ILIAS\Tests\Refinery\Encode\Transformation\URLTest\testInvalidEncoding(), ILIAS\Tests\Refinery\Encode\Transformation\HTMLAttributeValueTest\testInvalidType(), ILIAS\Tests\Refinery\Encode\Transformation\HTMLSpecialCharsAsEntitiesTest\testInvalidType(), ILIAS\Tests\Refinery\Encode\Transformation\URLTest\testInvalidType(), ILIAS\Tests\Refinery\ConstantTransformationTest\testTransform(), ILIAS\Tests\Refinery\IdentityTransformationTest\testTransform(), ILIAS\Tests\Refinery\Encode\Transformation\HTMLSpecialCharsAsEntitiesTest\testTransform(), ILIAS\Tests\Refinery\Encode\Transformation\URLTest\testTransform(), ILIAS\Tests\Refinery\Encode\Transformation\HTMLAttributeValueTest\testTransform(), ILIAS\Tests\Refinery\Encode\Transformation\JsonTest\testTransform(), ILIAS\Tests\Refinery\Random\Transformation\ShuffleTransformationTest\testTransformResultFailure(), ILIAS\Tests\Refinery\Random\Transformation\ShuffleTransformationTest\testTransformResultSuccess(), assMatchingQuestion\toJSON(), and ILIAS\Refinery\Parser\ABNF\Brick\transformation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withProblemBuilder()

ILIAS\Refinery\withProblemBuilder ( callable  $builder)
final

Definition at line 32 of file ProblemBuilder.php.

32 : self
33 {
34 $clone = clone $this;
35 $clone->error = $builder;
36 return $clone;
37 }