Payload
API reference › Debug Core › Storage › Payload
Provides strict reads for DTO factories at the decoded-JSON boundary.
It validates types and shapes without accepting numeric strings, casting values, or supplying implicit defaults.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
all() | Returns every decoded field without conversion. | Payload |
bool() | Returns a required boolean field. | Payload |
debugArray() | Reads a tagged array value, keeping the path of the enclosing payload for error reporting. | Payload |
int() | Returns a required integer field. | Payload |
list() | Returns a required list field. | Payload |
map() | Returns a required JSON object as a string-keyed array. | Payload |
mapList() | Reads a list field and maps every element through a factory, passing the indexed element path for error reporting. | Payload |
nullableBool() | Returns a boolean field or null. | Payload |
nullableInt() | Returns an integer field or null. | Payload |
nullableNumber() | Returns a numeric field as a float or null. | Payload |
nullableString() | Returns a string field or null. | Payload |
number() | Returns a required numeric field as a float. | Payload |
object() static | Creates a strict reader for a decoded JSON object. | Payload |
raw() | Returns a required field without conversion. | Payload |
rows() | Reads a list of JSON objects, validating each element’s shape but leaving its values untouched. | Payload |
shape() | Validates required, optional, and undeclared fields. | Payload |
string() | Returns a required string field. | Payload |
Method details
Section titled “Method details”all()
Section titled “all() ”public function all(): array<string, mixed>Returns every decoded field without conversion.
Returns
array<string, mixed>: Decoded object fields.
bool()
Section titled “bool() ”public function bool(string $key): boolReturns a required boolean field.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | Required field name. |
Returns
bool: Boolean field value.
debugArray()
Section titled “debugArray() ”public function debugArray(string $key): PHPForge\Debug\Storage\DebugArrayReads a tagged array value, keeping the path of the enclosing payload for error reporting.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | Required field name. |
Returns
DebugArray: Hydrated tagged array.
int()
Section titled “int() ”public function int(string $key): intReturns a required integer field.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | Required field name. |
Returns
int: Integer field value.
list()
Section titled “list() ”public function list(string $key): list<mixed>Returns a required list field.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | Required field name. |
Returns
list<mixed>: List field value.
map()
Section titled “map() ”public function map(string $key): array<string, mixed>Returns a required JSON object as a string-keyed array.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | Required field name. |
Returns
array<string, mixed>: Object field value.
mapList()
Section titled “mapList() ”public function mapList(string $key, callable(mixed, string): PHPForge\Debug\Storage\T $factory): list<PHPForge\Debug\Storage\T>Reads a list field and maps every element through a factory, passing the indexed element path for error reporting.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | Required field name. |
$factory | callable(mixed, | Element factory receiving the raw element and its indexed path. |
Returns
list<PHPForge\Debug\Storage\T>: Mapped elements in payload order.
nullableBool()
Section titled “nullableBool() ”public function nullableBool(string $key): bool|nullReturns a boolean field or null.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | Required field name. |
Returns
bool|null: Boolean field value or null.
nullableInt()
Section titled “nullableInt() ”public function nullableInt(string $key): int|nullReturns an integer field or null.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | Required field name. |
Returns
int|null: Integer field value or null.
nullableNumber()
Section titled “nullableNumber() ”public function nullableNumber(string $key): float|nullReturns a numeric field as a float or null.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | Required field name. |
Returns
float|null: Numeric field value or null.
nullableString()
Section titled “nullableString() ”public function nullableString(string $key): string|nullReturns a string field or null.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | Required field name. |
Returns
string|null: String field value or null.
number()
Section titled “number() ”public function number(string $key): floatReturns a required numeric field as a float.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | Required field name. |
Returns
float: Numeric field value.
object()
Section titled “object() ”public static function object(mixed $value, string $path = '$'): selfCreates a strict reader for a decoded JSON object.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | Decoded JSON value. |
$path | string | Object path used in hydration errors. |
Returns
self: Strict object reader.
raw()
Section titled “raw() ”public function raw(string $key): mixedReturns a required field without conversion.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | Required field name. |
Returns
mixed: Unconverted field value.
rows()
Section titled “rows() ”public function rows(string $key): list<array<string, mixed>>Reads a list of JSON objects, validating each element’s shape but leaving its values untouched.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | Required field name. |
Returns
list<array<string, mixed>>: Validated object rows.
shape()
Section titled “shape() ”public function shape(list<string> $required, list<string> $optional = []): selfValidates required, optional, and undeclared fields.
Parameters
| Parameter | Type | Description |
|---|---|---|
$required | list<string> | Required field names. |
$optional | list<string> | Optional field names. |
Returns
self: Validated object reader.
string()
Section titled “string() ”public function string(string $key): stringReturns a required string field.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | Required field name. |
Returns
string: String field value.