ILIAS  release_8 Revision v8.24
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)
 
 transform ($from)
 @inheritDoc More...
 
- Public Member Functions inherited from ILIAS\Refinery\Transformation
 transform ($from)
 Perform the transformation. More...
 
 applyTo (Result $result)
 Perform the transformation and reify possible failures. More...
 
 __invoke ($from)
 Transformations should be callable. More...
 

Protected Member Functions

 getError ()
 @inheritDoc More...
 

Private Attributes

array $transformations
 
Data Factory $data_factory
 
 $error
 

Detailed Description

Definition at line 26 of file ByTrying.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Refinery\ByTrying::__construct ( array  $transformations,
Data\Factory  $data_factory 
)
Parameters
Transformation[]$transformations
Data\Factory$data_factory

Definition at line 42 of file ByTrying.php.

43 {
44 $this->transformations = $transformations;
45 $this->data_factory = $data_factory;
46 $this->error = static function (): void {
47 throw new ConstraintViolationException(
48 'no valid constraints',
49 'no_valid_constraints'
50 );
51 };
52 }
Data Factory $data_factory
Definition: ByTrying.php:34
error(string $a_errmsg)

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

@inheritDoc

Definition at line 57 of file ByTrying.php.

57 : callable
58 {
59 return $this->error;
60 }

References ILIAS\Refinery\ByTrying\$error.

◆ transform()

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

@inheritDoc

Implements ILIAS\Refinery\Transformation.

Definition at line 65 of file ByTrying.php.

66 {
67 foreach ($this->transformations as $transformation) {
68 $result = $this->data_factory->ok($from);
69 $result = $transformation->applyTo($result);
70 if ($result->isOK()) {
71 return $result->value();
72 }
73 }
74 throw new Exception($this->getErrorMessage($from));
75 }
getErrorMessage($value)
Get the problem message.

References ILIAS\Refinery\getErrorMessage().

+ Here is the call graph for this function:

Field Documentation

◆ $data_factory

Data Factory ILIAS\Refinery\ByTrying::$data_factory
private

Definition at line 34 of file ByTrying.php.

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

◆ $error

ILIAS\Refinery\ByTrying::$error
private

Definition at line 36 of file ByTrying.php.

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

◆ $transformations

array ILIAS\Refinery\ByTrying::$transformations
private

Definition at line 33 of file ByTrying.php.

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


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