ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
MapValues.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use InvalidArgumentException;
27
31class MapValues implements Transformation
32{
35
36 protected string $type;
38
40 {
41 $this->trafo = $trafo;
42 }
43
47 public function transform($from): array
48 {
49 if (!is_array($from)) {
50 throw new InvalidArgumentException(__METHOD__ . " argument is not an array.");
51 }
52
53 return array_map(function ($a) {
54 return $this->trafo->transform($a);
55 }, $from);
56 }
57}
Adds to any array keys for each value.
Definition: MapValues.php:32
__construct(Transformation $trafo)
Definition: MapValues.php:39
A transformation is a function from one datatype to another.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples