x-o-r / walker
Easily and securely retrieve some values in datas
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/x-o-r/walker
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ^6.4
This package is not auto-updated.
Last update: 2025-12-25 10:49:54 UTC
README
Easily and securely access all targeted data nodes at different depths in data !
Usage
Retrieve Foo->Bar
(new Walker) ->from( (object)["Foo" => (object)["Bar" => "Value"] ]) ->with('Foo->Bar') ->asString(); /* Will return 'Value' */
Retrieve Foo->Bar in JSON stream
(new Walker) ->fromJson('{ "Foo": { "Bar": "Value" } }') ->with('Foo->Bar') ->asString(); /* Will return 'Value' */
Retrieve Foo->Bar and Walker->Texas->Ranger
(new Walker) ->from([ (object)["Foo" =>(object)["Bar" => "Some"]], (object)["Walker" =>(object)["Texas" => (object)["Ranger" => "values"]]] ]) ->with('Foo->Bar') ->with('Walker->Texas->Ranger') ->asString(); /* Will return 'Some, values' */
With values located at different depths
(new Walker) ->from([ (object)["Walker" => (object)["Texas" => (object) ['Ranger' => 'All'] ] ], (object)["Walker" => [ (object)["Texas" => (object)["Ranger" => "targets"]], (object)['Texas' => (object)['Ranger' => 'are']], ] ], (object)['Walker' => (object)['Texas' => (object)['Ranger' => 'retrieved']]] ]) ->with('Walker->Texas->Ranger') ->asString(function($founds) { return join(' ', $founds); }); /* Will return 'All targets are retrieved' */