ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ListTransformation.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 
28 {
31 
33 
34  public function __construct(Transformation $transformation)
35  {
36  $this->transformation = $transformation;
37  }
38 
42  public function transform($from): array
43  {
44  if (!is_array($from)) {
45  $from = [$from];
46  }
47 
48  $result = [];
49  foreach ($from as $val) {
50  $transformedVal = $this->transformation->transform($val);
51  $result[] = $transformedVal;
52  }
53 
54  return $result;
55  }
56 }
A transformation is a function from one datatype to another.