ILIAS  release_7 Revision v7.30-3-g800a261c036
DictionaryTransformation.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
15
17{
20
25
30 {
31 $this->transformation = $transformation;
32 }
33
37 public function transform($from)
38 {
39 if (false === is_array($from)) {
41 'The value MUST be an array',
42 'not_array'
43 );
44 }
45
46 $result = array();
47 foreach ($from as $key => $value) {
48 if (false === is_string($key)) {
50 'The key "%s" is NOT a string',
51 'key_is_not_a_string'
52 );
53 }
54
55 $transformedValue = $this->transformation->transform($value);
56 $result[$key] = $transformedValue;
57 }
58
59 return $result;
60 }
61}
$result
An exception for terminatinating execution or to throw for unit testing.
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.