mrubiosan/loose-schema-navigator

Carefree traversal of data structures with eventual strict typing

1.2.1 2022-10-07 08:55 UTC

This package is auto-updated.

Last update: 2024-11-07 13:24:27 UTC


README

Build Status Maintainability Test Coverage

Example usage

$data = <<<JSONSTR
{
	"foo":"123",
	"bar":{
		"baz": "true",
		"buzz": "{\"abc\":\"xyz\"}"
	}
}
JSONSTR;

$nav = new Navigator($data);

$nav->foo->int(); // 123
$nav->foo->string(); // "123"
$nav->missingProp->int(); // 0
$nav->missingProp->int(-1); // -1
$nav->bar->baz->int(); // 1
$nav->bar->baz->bool(); // true
$nav->bar->buzz->string(); //  "{"abc":"xyz"}"
$nav->bar->buzz->object(); //  {"abc":"xyz"}
$nav->bar->buzz->array(); //  ["abc" => "xyz"]
$nav->bar->buzz->abc->string(); // "xyz"