$parent
$parent :
Data Object -- Base class for all Nano4\Data classes.
These are "magic" objects which are meant for converting data between different formats easily, with PHP arrays, JSON and XML as the default targets.
The load() method, which can be used in the constructor, will determine the data type either by a 'type' parameter passed to it, or by calling the detect_datatype() method (a default version is supplied, feel free to override it, or create chains using parent:: calls.) when the type has been determined, the data will be passed to a method called load$type() which will be used to load the data.
It is expected that custom methods to perform operations on the data will be added, as well as operations to return the data in specific formats (typically the same ones that you accept in the load() statement.)
The default version can load PHP arrays, plus JSON and YAML strings. It also has to_array(), to_json() and to_yaml() methods to return in those formats. The JSON and YAML methods wrap around the array ones, so overriding the array methods is all you really need to do. The default versions perform no transformations, but simply set our data to the PHP array result.
This will also detect SimpleXML and DOM objects, and XML strings. In order to load any of the above objects, you need to implement the load_simple_xml() method (XML strings and DOM objects will be converted to SimpleXMLElement objects and passed through.)
In order to use the to_dom_document(), to_dom_element() or to_xml() methods you must implement a to_simple_xml() method first (again for simplicity we call to_simple_xml() then convert the object it return to the desired format.)
Add extra formats as desired, chaining the detect_data_type() and detect_string_type() methods is easy, so go crazy!
__construct_data( $mixed = Null, $opts = Null)
Internal constructor method.
Supports two forms, the original form has the data as the first parameter, and a set of options as the second.
The second form sends the options as the first parameter, with a named 'data' option to specify the data. In this case, the second parameter should be left off.
| $mixed | ||
| $opts |