ILIAS  release_7 Revision v7.30-3-g800a261c036
ILIAS\Refinery\ByTrying Class Reference
+ Inheritance diagram for ILIAS\Refinery\ByTrying:
+ Collaboration diagram for ILIAS\Refinery\ByTrying:

Public Member Functions

 __construct (array $transformations, Data\Factory $data_factory, \ilLanguage $lng)
 
 transform ($from)
 Perform the transformation.Please use this for transformations. It's more performant than calling invoke.
Exceptions

InvalidArgumentException if the argument could not be transformed

Parameters
mixed$from
Returns
mixed
More...
 
- Public Member Functions inherited from ILIAS\Refinery\Transformation
 transform ($from)
 Perform the transformation. More...
 
 applyTo (Result $data)
 Perform the transformation and reify possible failures. More...
 
 __invoke ($from)
 Transformations should be callable. More...
 

Protected Member Functions

 getError ()
 

Protected Attributes

 $transformations
 
 $data_factory
 
 $error
 

Detailed Description

Definition at line 14 of file ByTrying.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Refinery\ByTrying::__construct ( array  $transformations,
Data\Factory  $data_factory,
\ilLanguage  $lng 
)

Definition at line 35 of file ByTrying.php.

36 {
37 $this->transformations = $transformations;
38 $this->data_factory = $data_factory;
39 $this->error = function () {
40 throw new ConstraintViolationException(
41 'no valid constraints',
42 'no_valid_constraints'
43 );
44 };
45 }
error($a_errmsg)
set error message @access public

References ILIAS\Refinery\ByTrying\$data_factory, ILIAS\Refinery\ByTrying\$transformations, and error().

+ Here is the call graph for this function:

Member Function Documentation

◆ getError()

ILIAS\Refinery\ByTrying::getError ( )
protected

Definition at line 50 of file ByTrying.php.

51 {
52 return $this->error;
53 }

References ILIAS\Refinery\ByTrying\$error.

◆ transform()

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

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

Exceptions

InvalidArgumentException if the argument could not be transformed

Parameters
mixed$from
Returns
mixed

Implements ILIAS\Refinery\Transformation.

Definition at line 58 of file ByTrying.php.

59 {
60 foreach ($this->transformations as $transformation) {
61 $result = $this->data_factory->ok($from);
62 $result = $transformation->applyTo($result);
63 if ($result->isOK()) {
64 return $result->value();
65 }
66 }
67 throw new \Exception($this->getErrorMessage($from));
68 }
$result
getErrorMessage($value)
Get the problem message.

References $result, and ILIAS\Refinery\getErrorMessage().

+ Here is the call graph for this function:

Field Documentation

◆ $data_factory

ILIAS\Refinery\ByTrying::$data_factory
protected

Definition at line 28 of file ByTrying.php.

Referenced by ILIAS\Refinery\ByTrying\__construct().

◆ $error

ILIAS\Refinery\ByTrying::$error
protected

Definition at line 33 of file ByTrying.php.

Referenced by ILIAS\Refinery\ByTrying\getError().

◆ $transformations

ILIAS\Refinery\ByTrying::$transformations
protected

Definition at line 23 of file ByTrying.php.

Referenced by ILIAS\Refinery\ByTrying\__construct().


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