ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
FinalizeNormalizing.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25
31final class FinalizeNormalizing implements Processor
32{
33 public function process(object $carry): void
34 {
35 if (!($carry instanceof NormalizeCarry)) {
36 return;
37 }
38
39 if ($carry->hasResult()) {
40 $this->ensureNormalized($carry->result());
41 }
42 }
43
44 private function ensureNormalized(mixed $value): mixed
45 {
46 if (is_scalar($value) || $value === null) {
47 return $value;
48 }
49
50 if (is_array($value)) {
51 return array_map($this->ensureNormalized(...), $value);
52 }
53
54 throw new NormalizingException('Value is not normalized: ' . get_debug_type($value));
55 }
56}
Exception thrown when a value cannot be normalized or denormalized.
Finalize the normalization of the value by ensuring that the value is normalized.
Carries a value, context and eventual result through normalization processors.