ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ListTransformation.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
10
14
16{
22
27 {
28 $this->transformation = $transformation;
29 }
30
34 public function transform($from)
35 {
36 if (false === is_array($from)) {
38 'The input value must be an array',
39 'must_be_array'
40 );
41 }
42
43 $result = [];
44 foreach ($from as $value) {
45 $transformedValue = $this->transformation->transform($value);
46 $result[] = $transformedValue;
47 }
48
49 return $result;
50 }
51
55 public function __invoke($from)
56 {
57 return $this->transform($from);
58 }
59}
$result
An exception for terminatinating execution or to throw for unit testing.
__invoke($from)
Transformations should be callable.This MUST do the same as transform.InvalidArgumentException if the...
transform($from)
Perform the transformation.Please use this for transformations. It's more performant than calling inv...
A transformation is a function from one datatype to another.