Oihana PHP Arango

unwrapField.php

Table of Contents

Functions

unwrapField()  : mixed
Extracts a single wrapper field from a server response body, with a typed fallback when the field is missing or the body itself is not an array.

Functions

unwrapField()

Extracts a single wrapper field from a server response body, with a typed fallback when the field is missing or the body itself is not an array.

unwrapField(mixed $body, string $field[, mixed $fallback = null ]) : mixed

ArangoDB consistently wraps payloads inside an envelope on its /_api/gharial/* and /_api/transaction/* endpoints:

{ "graph"  : { ... } }      // GET /_api/gharial/{name}
{ "vertex" : { ... } }      // GET /_api/gharial/{g}/vertex/{c}/{k}
{ "edge"   : { ... } }      // GET /_api/gharial/{g}/edge/{c}/{k}
{ "result" : { ... } }      // GET /_api/transaction/{id}

unwrapField() reads that wrapper and returns the inner payload (or $fallback when the wrapper is absent / malformed). Pure function — no side effects, defensive against partial responses.

Parameters
$body : mixed

Decoded response body.

$field : string

Name of the wrapper field to extract.

$fallback : mixed = null

Value to return when $body is not an array, or when the field is missing or not an array itself.

Return values
mixed

The unwrapped payload, or $fallback.

On this page

Search results