[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/core/src/ -> lmbObject.class.php (summary)

(no description)

File Size: 306 lines (7 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

lmbObject:: (26 methods):
  __construct()
  getClass()
  getHash()
  import()
  export()
  has()
  hasAttribute()
  getAttributesNames()
  get()
  remove()
  removeAll()
  reset()
  _getRaw()
  _getObjectVars()
  set()
  offsetExists()
  offsetGet()
  offsetSet()
  offsetUnset()
  _setRaw()
  _isGuarded()
  __call()
  _mapGetToProperty()
  _mapSetToProperty()
  _mapPropertyToMethod()
  _mapPropertyToSetMethod()


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>

__construct($attributes = array()   X-Ref
Constructor.
Fills internals properties if any

param: array properties array

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

import($values)   X-Ref
Merges existing properties with new ones

param: array

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

hasAttribute($name)   X-Ref


getAttributesNames()   X-Ref
Returns array filled with attribute names

return: array

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

remove($name)   X-Ref
Removes specified property

param: string

removeAll()   X-Ref


reset()   X-Ref
Removes all object properties


_getRaw($name)   X-Ref
No description

_getObjectVars()   X-Ref
No description

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

offsetExists($offset)   X-Ref
No description

offsetGet($offset)   X-Ref
No description

offsetSet($offset, $value)   X-Ref
No description

offsetUnset($offset)   X-Ref
No description

_setRaw($name, $value)   X-Ref
No description

_isGuarded($property)   X-Ref
No description

__call($method, $args = array()   X-Ref
No description

_mapGetToProperty($method)   X-Ref
No description

_mapSetToProperty($method)   X-Ref
No description

_mapPropertyToMethod($property)   X-Ref
No description

_mapPropertyToSetMethod($property)   X-Ref
No description



Generated: Mon Sep 8 04:35:41 2008 Cross-referenced by PHPXref 0.7