Open
Description
When you call get('some.node')
if the node doesn't exist you get null
(or pass a default value) .
Suggest adding getAsCollection()
to ensure a collection is always returned regardless of whether the node exists, or if the node is an item/collection. This is useful due to chaining.
Example:
$response->getAsCollection('recipients.data')->each(function($recipient) { ... });
- If the node doesn't exist an empty (ArrayObject) collection will be returned
- If the node exists but isn't a collection (eg. a scalar or an associative array), then it will be wrapped in a collection with a single item