-
Notifications
You must be signed in to change notification settings - Fork 0
Class: Nether\Object\Datastore
Bob Magic II edited this page Aug 18, 2021
·
14 revisions
This class is a wrapper for arrays to allow datasets to be treated as both arrays and objects with chainable helper methods. To start with you give it an array of data you want to work with, or nothing for an empty dataset.
$Dataset = [
'Captain' => 'Benjamin Sisko',
'Chief Engineer' => 'Miles O\'Brien',
'Science Officer' => 'Jadzia Dax'
];
$Data = new Nether\Object\Datastore($Dataset);
print_r($Data);
Nether\Object\Datastore Object
(
[Captain] => Benjamin Sisko
[Chief Engineer] => Miles O'Brien
[Science Officer] => Jadzia Dax
)
On the surface Datastore objects can be treated like normal arrays...
var_dump($Data['Captain']);
foreach($Data as $Key => $Val)
printf('%s: %s%s', $Key, $Val, PHP_EOL);
string(14) "Benjamin Sisko"
Captain: Benjamin Sisko
Chief Engineer: Miles O'Brien
Science Officer: Jadzia Dax