DataObject
Implements DumpableInterface, IteratorAggregate, JsonSerializable, CountableDataObject is a class that is used to store data but allowing you to access the data by mimicking the way PHP handles class properties.
| since |
1.0 |
|---|---|
| package |
Joomla Framework |
Methods
__construct
The class constructor.
__construct(mixed properties = array()) : mixed
| since |
1.0 |
|---|---|
| throws |
|
Arguments
- properties
mixedEither an associative array or another object by which to set the initial properties of the new object.
Response
mixed
__get
The magic get method is used to get a data property.
__get(string property) : mixed
This method is a public proxy for the protected getProperty method.
Note: Magic __get does not allow recursive calls. This can be tricky because the error generated by recursing into __get is "Undefined property: {CLASS}::{PROPERTY}" which is misleading. This is relevant for this class because requesting a non-visible property can trigger a call to a sub-function. If that references the property directly in the object, it will cause a recursion into __get.
| see | DataObject::getProperty() |
|---|---|
| since |
1.0 |
Arguments
- property
stringThe name of the data property.
Response
mixedThe value of the data property, or null if the data property does not exist.
__isset
The magic isset method is used to check the state of an object property.
__isset(string property) : bool
| since |
1.0 |
|---|
Arguments
- property
stringThe name of the data property.
Response
boolTrue if set, otherwise false is returned.
__set
The magic set method is used to set a data property.
__set(string property, mixed value) : void
This is a public proxy for the protected setProperty method.
| see | DataObject::setProperty() |
|---|---|
| since |
1.0 |
Arguments
- property
stringThe name of the data property.- value
mixedThe value to give the data property.
__unset
The magic unset method is used to unset a data property.
__unset(string property) : void
| since |
1.0 |
|---|
Arguments
- property
stringThe name of the data property.
bind
Binds an array or object to this object.
bind(mixed properties, bool updateNulls = true) : \Joomla\Data\DataObject
| since |
1.0 |
|---|---|
| throws |
|
Arguments
- properties
mixedAn associative array of properties or an object.- updateNulls
boolTrue to bind null values, false to ignore null values.
Response
\Joomla\Data\DataObjectReturns itself to allow chaining.
count
Count the number of data properties.
count() : int
| since |
1.0 |
|---|
Response
intThe number of data properties.
dump
Dumps the data properties into a stdClass object, recursively if appropriate.
dump(int depth = 3, \SplObjectStorage dumped = null) : \stdClass
| since |
1.0 |
|---|
Arguments
- depth
intThe maximum depth of recursion (default = 3). For example, a depth of 0 will return a stdClass with all the properties in native form. A depth of 1 will recurse into the first level of properties only.- dumped
\SplObjectStorageAn array of already serialized objects that is used to avoid infinite loops.
Response
\stdClassThe data properties as a simple PHP stdClass object.
dumpProperty
Dumps a data property.
dumpProperty(string property, int depth, \SplObjectStorage dumped) : mixed
If recursion is set, this method will dump any object implementing Data\Dumpable (like Data\Object and Data\Set); it will convert a Date object to a string; and it will convert a Registry to an object.
| since |
1.0 |
|---|
Arguments
- property
stringThe name of the data property.- depth
intThe current depth of recursion (a value of 0 will ignore recursion).- dumped
\SplObjectStorageAn array of already serialized objects that is used to avoid infinite loops.
Response
mixedThe value of the dumped property.
getIterator
Gets this object represented as an ArrayIterator.
getIterator() : \ArrayIterator
This allows the data properties to be access via a foreach statement.
| see | IteratorAggregate::getIterator() |
|---|---|
| since |
1.0 |
Response
\ArrayIteratorThis object represented as an ArrayIterator.
getProperty
Gets a data property.
getProperty(string property) : mixed
| see | DataObject::__get() |
|---|---|
| since |
1.0 |
Arguments
- property
stringThe name of the data property.
Response
mixedThe value of the data property.
jsonSerialize
Gets the data properties in a form that can be serialised to JSON format.
jsonSerialize() : string
| since |
1.0 |
|---|
Response
stringAn object that can be serialised by json_encode().
setProperty
Sets a data property.
setProperty(string property, mixed value) : mixed
If the name of the property starts with a null byte, this method will return null.
| see | DataObject::__set() |
|---|---|
| since |
1.0 |
Arguments
- property
stringThe name of the data property.- value
mixedThe value to give the data property.
Response
mixedThe value of the data property.
Properties
properties
The data object properties.
| since |
1.0 |
|---|
Type(s)
array