ILIAS  release_8 Revision v8.24
MapValues.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
27use InvalidArgumentException;
28
32class MapValues implements Transformation
33{
36
37 protected string $type;
39
41 {
42 $this->trafo = $trafo;
43 }
44
48 public function transform($from): array
49 {
50 if (!is_array($from)) {
51 throw new InvalidArgumentException(__METHOD__ . " argument is not an array.");
52 }
53
54 return array_map(function ($a) {
55 return $this->trafo->transform($a);
56 }, $from);
57 }
58}
Builds data types.
Definition: Factory.php:21
Adds to any array keys for each value.
Definition: MapValues.php:33
__construct(Transformation $trafo)
Definition: MapValues.php:40
A transformation is a function from one datatype to another.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: AddLabels.php:21
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples