assertDocumentKeyValid.php
Table of Contents
Functions
- assertDocumentKeyValid() : bool
- Validates the key, separator, and type of the provided document before performing key-based operations.
Functions
assertDocumentKeyValid()
Validates the key, separator, and type of the provided document before performing key-based operations.
assertDocumentKeyValid(array<string|int, mixed>|object $document, string $key[, string $separator = '.' ][, bool|null &$isArray = null ]) : bool
This internal helper ensures that:
- The key is not empty.
- The separator is not empty.
- The document matches the expected type (
array
orobject
), or infers the type if$isArray
is null.
If a mismatch between the inferred or forced type and the actual document type occurs,
an InvalidArgumentException
is thrown.
Parameters
- $document : array<string|int, mixed>|object
-
The input document (either an array or an object).
- $key : string
-
The key or property name/path to validate.
- $separator : string = '.'
-
The separator for nested paths (default is '.').
- $isArray : bool|null = null
-
Optional reference:
true
for array,false
for object,null
to infer automatically.
Tags
Return values
bool —Returns the resolved value of $isArray
: true
for array, false
for object.