Class: lmbObject - X-Ref
Generic container for data with magic accessors.
NOTE: All properties are stored as attributes of an object. If you need to
make certain properties 'guarded', you should prefix these properties
with "_" symbol.
<b>Basic usage</b>
<code>
//filling object
$obj = new lmbObject(array('foo' => 'bar'));
//the getter calls below are equal
$obj->get('foo');
$obj->getFoo();
$obj['foo'];
//the setter calls below are equal
$obj->set('foo', 'hey');
$obj->setFoo('hey');
$obj['foo'] = 'hey';
</code>
<b>Mapping generic getters to fine-grained methods</b>
<code>
class Foo extends lmbObject
{
function getBar()
{
return 'bar';
}
}
$foo = new Foo();
//the call below will be magically mapped to getBar() method
//this can be very useful for WACT templates, e.g. {$bar} in
//template will trigger the same method getBar() as well
$foo->get('bar');
</code>
<b>Mapping generic setters to fine-grained methods</b>
<code>
class Foo extends lmbObject
{
function setBar($value)
{
$this->_setRaw('bar', (int)$value);
}
}
$foo = new Foo();
//the call below will be magically mapped to setBar($value) method
//this can be useful if some property processing is required
$foo->set('bar', '10.0');
</code>
<b>Working with deep nested values</b>
<code>
$obj = new lmbObject(array('foo' => array('bar' => 'hey')));
//would print 'hey'
echo $obj->getByPath('foo.bar');
</code>
|
getClass()
X-Ref
|
Returns class name using PHP built in get_class
return: string
|
|
getHash()
X-Ref
|
Returns object's hash in md5 form
return: string
|
|
export()
X-Ref
|
Exports all object properties as an array
return: array
|
|
has($name)
X-Ref
|
Checks if such attribute exists
return: bool returns true even if attribute is null
|
|
get($name)
X-Ref
|
Returns property value if it exists and not guarded.
Magically maps getter to fine-grained method if it exists, e.g. get('foo') => getFoo()
param: string property name
return: mixed|null
|
|
set($name, $value)
X-Ref
|
Sets property value
Magically maps setter to fine-grained method if it exists, e.g. set('foo', $value) => setFoo($value)
param: string property name
param: mixed value
|