Public Member Functions | |
__construct ($cloValidator=null, array $arrData=array()) | |
add (array $arrData) | |
delete ($strKey) | |
exists ($strKey) | |
get ($strKey) | |
getAll () | |
update (array $arrData) | |
Private Attributes | |
$arrData = array() | |
$cloValidator = null | |
a DataObject is a generic object to store data under given keys.
it allows getting, adding, updating and deleting data.
a validation callback can be provided to ensure, that the stored data validate correctly.
Definition at line 17 of file DataObject.class.php.
DDDBL\DataObject::__construct | ( | $cloValidator = null , |
|
array | $arrData = array() |
||
) |
$cloValidator | - optional validator callback to validate stored data |
$arrData | - optional list of data to store in object |
UnexpectedParameterTypeException | - if validator callback is not a callable |
initiates the data-object and stores the validator callback. if no callback is given, a default callback is stored, which validates against everything.
if optional data are given, they are passed to DataObject::add(), to be stored immediatley
Definition at line 43 of file DataObject.class.php.
DDDBL\DataObject::add | ( | array | $arrData | ) |
$arrData | - list of data to store in object |
\Exception | - if a key is already in use |
\Exception | - if the final data-set do not validate |
add the list of data to the existing ones. the given data must have the following format: array([key] => data [key] => data, [..])
if a key in the given data is already used in stored data the addition is aborted and an exception is thrown.
the stored data are only modified on success
Definition at line 73 of file DataObject.class.php.
DDDBL\DataObject::delete | ( | $strKey | ) |
$strKey | - the key of the value to delete |
UnexpectedParameterTypeException | - if given key is not a string |
delete the value stored under the given key. if given key do not exists, nothing is done!
Definition at line 127 of file DataObject.class.php.
DDDBL\DataObject::exists | ( | $strKey | ) |
$strKey | - the key to check |
UnexpectedParameterTypeException | - if given key is not a string |
check if the given key exists
Definition at line 148 of file DataObject.class.php.
DDDBL\DataObject::get | ( | $strKey | ) |
$strKey | - the key to get the value from |
UnexpectedParameterTypeException | - if given key is not a string |
\Exception | - if given key is unknown |
return the value stored under the given key
Definition at line 171 of file DataObject.class.php.
DDDBL\DataObject::getAll | ( | ) |
return all stored data in the structure of: array([key] => data [key] => data, [..])
Definition at line 189 of file DataObject.class.php.
DDDBL\DataObject::update | ( | array | $arrData | ) |
$arrData | - list of data to update |
\Exception | - if the final data-set do not validate |
update the stored data with the given data-set. for the structure of $arrData have a look at DataObject:add()
existing keys are overwritten with new values. new keys are added to the data-set.
if validation of final set fails, an exception is thrown. no data are modified on failure.
Definition at line 105 of file DataObject.class.php.
|
private |
list of stored data
Definition at line 22 of file DataObject.class.php.
|
private |
callback to validate all stored data
Definition at line 27 of file DataObject.class.php.