ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
DenormalizeCarry.php
Go to the documentation of this file.
1<?php
2
4
7
12{
13 private bool $has_result = false;
14 private mixed $result;
15
19 public function __construct(
20 private readonly Transformations $transformations,
21 private readonly array|float|bool|int|string|null $normalized,
22 private readonly string|object $expected,
23 ) {
24 }
25
27 {
28 return $this->transformations;
29 }
30
32 public function normalized(): array|float|bool|int|string|null
33 {
34 return $this->normalized;
35 }
36
37 public function expected(): string|object
38 {
39 return $this->expected;
40 }
41
42 public function hasResult(): bool
43 {
44 return $this->has_result;
45 }
46
47 public function setResult(mixed $result): void
48 {
49 $this->result = $result;
50 $this->has_result = true;
51 }
52
58 public function result(): mixed
59 {
60 if ($this->has_result === false) {
61 throw new NormalizingException(sprintf(
62 'Unsupported value, expected: %s, got: %s',
63 get_debug_type($this->expected),
64 get_debug_type($this->normalized)
65 ));
66 }
67
68 return $this->result;
69 }
70}
Exception thrown when a value cannot be normalized or denormalized.
Carries normalized data, its expected type and eventual result through denormalization processors.
__construct(private readonly Transformations $transformations, private readonly array|float|bool|int|string|null $normalized, private readonly string|object $expected,)
Provides a set of transformations for normalizing and denormalizing values.