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
More...
 
- Public Member Functions inherited from ILIAS\Refinery\Transformation
 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.

References ILIAS\Refinery\ByTrying\$data_factory, and ILIAS\Refinery\ByTrying\$transformations.

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  }

Member Function Documentation

◆ getError()

ILIAS\Refinery\ByTrying::getError ( )
protected

Definition at line 50 of file ByTrying.php.

References ILIAS\Refinery\ByTrying\$error.

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

◆ transform()

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

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

Exceptions

Implements ILIAS\Refinery\Transformation.

Definition at line 58 of file ByTrying.php.

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

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