AXIAM PHP SDK

ModelDecode
in package

FinalYes

Reads a REQUIRED field out of a decoded response body.

Hand-written rather than generated, and used by all 145 generated models.

Without it, a server response missing a field openapi.json declares required fails as PHP's own Undefined array key warning and then, in production where warnings are not exceptions, as a TypeError several frames inside a constructor — neither of which names the field, the model, or the fact that the SERVER sent something unexpected. An operator reading that has no way to tell a truncated response from an SDK bug.

This turns the whole class into one NetworkError that says which model wanted which field, which is both accurate (a short body IS a transport-level problem) and actionable.

Table of Contents

Methods

need()  : mixed
Returns `$data[$key]`, or throws naming the model that needed it.

Methods

need()

Returns `$data[$key]`, or throws naming the model that needed it.

public static need(array<string, mixed> $data, string $key, string $model) : mixed
Parameters
$data : array<string, mixed>

The decoded response body.

$key : string

The wire field name.

$model : string

The model being decoded, for the message.

Tags
throws
NetworkError

when the field is absent.

On this page

Search results