ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
Series.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3
4/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
5
10namespace ILIAS\Refinery\In;
11
15
16class Series implements Transformation
17{
23
27 public function __construct(array $transformations)
28 {
29 foreach ($transformations as $transformation) {
30 if (!$transformation instanceof Transformation) {
31 $transformationClassName = Transformation::class;
32
34 sprintf('The array MUST contain only "%s" instances', $transformationClassName),
35 'not_a_transformation',
36 $transformationClassName
37 );
38 }
39 }
40 $this->transformationStrategies = $transformations;
41 }
42
46 public function transform($from)
47 {
48 $result = $from;
49 foreach ($this->transformationStrategies as $strategy) {
50 $result = $strategy->transform($result);
51 }
52
53 return $result;
54 }
55
59 public function __invoke($from)
60 {
61 return $this->transform($from);
62 }
63}
$result
An exception for terminatinating execution or to throw for unit testing.
__construct(array $transformations)
Definition: Series.php:27
transform($from)
Perform the transformation.Please use this for transformations. It's more performant than calling inv...
Definition: Series.php:46
__invoke($from)
Transformations should be callable.This MUST do the same as transform.InvalidArgumentException if the...
Definition: Series.php:59
A transformation is a function from one datatype to another.