ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
Parallel.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types=1);
3 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
9 namespace ILIAS\Refinery\In;
10 
14 
15 class Parallel implements Transformation
16 {
22 
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  $results = array();
49  foreach ($this->transformationStrategies as $strategy) {
50  $results[] = $strategy->transform($from);
51  }
52 
53  return $results;
54  }
55 
59  public function __invoke($from)
60  {
61  return $this->transform($from);
62  }
63 }
__invoke($from)
Transformations should be callable.This MUST do the same as transform.
Definition: Parallel.php:59
__construct(array $transformations)
Definition: Parallel.php:27
transform($from)
Perform the transformation.Please use this for transformations. It&#39;s more performant than calling inv...
Definition: Parallel.php:46
$results
A transformation is a function from one datatype to another.