ILIAS  release_8 Revision v8.24
DictionaryTransformation.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
27
29{
32
34
36 {
37 $this->transformation = $transformation;
38 }
39
44 public function transform($from): array
45 {
46 if (!is_array($from)) {
48 sprintf('The value "%s" is no array.', var_export($from, true)),
49 'value_is_no_array',
50 $from
51 );
52 }
53
54 $result = [];
55 foreach ($from as $key => $value) {
56 if (!(is_int($key) || is_string($key))) {
58 'Key is not a string or int',
59 'key_is_no_string_or_int'
60 );
61 }
62 $transformedValue = $this->transformation->transform($value);
63 $result[(string) $key] = $transformedValue;
64 }
65
66 return $result;
67 }
68}
A transformation is a function from one datatype to another.
string $key
Consumer key/client ID value.
Definition: System.php:193
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...