Skip to content

API reference / Quittio \ Core \ Serialization

ArrayNormalizer

final class in quittio/core

Quittio\Core\Serialization\ArrayNormalizer · Source

Converts DTOs into plain arrays (scalars only) for JSON, storage and APIs.

Values equal to the constructor default are omitted to keep the output compact; the hydrator restores them from the defaults.

Methods#

MethodDescription
->normalize()
->value()Normalizes one value: amounts as strings with two decimals, decimals as strings, dates as ISO strings, enums and codes as their value, arrays element by element and other objects with normalize(). Null and scalars stay as they are.

normalize()#

public function normalize(object $dto): array<string, mixed>
ParameterTypeDescription
$dtoobject
Returns
array<string, mixed>

value()#

public function value(mixed $value): mixed

Normalizes one value: amounts as strings with two decimals, decimals as strings, dates as ISO strings, enums and codes as their value, arrays element by element and other objects with normalize(). Null and scalars stay as they are.

ParameterTypeDescription
$valuemixed
Returns
mixed

The open core packages are MIT licensed. The legal wording of the country packs must be confirmed by a tax adviser.