ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
TransformationNormalizer.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\Refinery\Factory as Refinery;
27
32{
33 public function __construct(private readonly Refinery $refinery) {
34 }
35
36 #[\Override]
37 public function normalize($value): array|float|bool|int|string|null
38 {
39 if ($value instanceof Transformation) {
40 return $value->transform([]);
41 }
42
43 throw new NormalizingException('Invalid transformation value', $value);
44 }
45
46 #[\Override]
47 public function denormalize(array|float|bool|int|string|null $value, string $type): Transformation
48 {
49 return $this->refinery->custom()->transformation(static fn() => $value);
50 }
51}
Builds data types.
Definition: Factory.php:36
denormalize(array|float|bool|int|string|null $value, string $type)
Converts a normalized form back into a value.
Exception thrown when a value cannot be normalized or denormalized.
A transformation is a function from one datatype to another.
A Normalizer is responsible for converting a value into a normalized form and back.
Definition: Normalizer.php:35