Gumbo_Collection
Standard Collection Class
Author(s): |
Michael Luster <mluster79@yahoo.com> |
License: | New BSD License |
Copyright: | Copyright (c) 2007, iBayou, Michael Luster |
Link: | http://sourceforge.net/projects/phpgumbo |
Version: | 0.0.1 |
Implements interfaces:
- Gumbo_Interface_Collection
- IteratorAggregate (internal interface)
Class Variables
Class Methods
Constructor (extra arguments sent to callback as is)
Parameter(s):
- (string) $func :: callback function/method name
- (string|StdClass) $cls :: callback class name or object
[ Top ]
Adds an Object to the Collection
Parameter(s):
- (StdClass) $obj
- (string|int) $key :: key reference name
- () $data
- throws:
Gumbo_Exception Implementation of:
[ Top ]public bool exists ( int|string $key ) [line 378]Verifies a Key exists
Parameter(s):
- (int|string) $key
Implementation of:
[ Top ]public StdClass get ( int|string $key ) [line 332]Returns the corresponding Object associated with the given key
Parameter(s):
- (int|string) $key
Implementation of:
[ Top ]public string|array getCallback ( ) [line 421]Returns the callback function/method
Implementation of:
[ Top ]Gumbo_Iterator Implementation of:
- IteratorAggregate::getIterator
[ Top ]public array getParams ( ) [line 429]Returns the parameters to pass to the callback
Implementation of:
[ Top ]public bool isLoaded ( ) [line 437]Returns if the Collection has been loaded
Implementation of:
[ Top ]size () > 0 Implementation of:
[ Top ]public void remove ( int|string $key ) [line 153]Removes an Object from the Collection
Parameter(s):
- (int|string) $key :: key name
- throws:
Gumbo_Exception Implementation of:
[ Top ]public void removeValue ( mixed $data ) [line 180]Removes a value from the List (not used)
Parameter(s):
- (mixed) $data
Implementation of:
[ Top ]!size() Implementation of:
[ Top ]public void setCallback ( string $name, [string|StdClass $obj] ) [line 241]Sets the callback function/method (extra arguments will be sent to callback as is)
The callback function will be called to load the contents of the Collection. The value could be a function name or a class method. A callback function/method should define a single argument, the Collection. When the callback is executed, the Collection will pass itself (by reference) to the function. The callback will set the values of the Collection.
To set a function:
To set a class/object method (3 methods):
- // substitute an Object ($obj) for "class_name" if necessary
Parameter(s):
- (string) $name :: function/method name (array should be (0=>"class",1=>"method"))
- (string|StdClass) $obj :: class name or Object reference
- precondition:
function/method callable - throws:
Gumbo_Exception Implementation of:
[ Top ]public void setType ( string $type ) [line 200]Sets the type of class|interface of the Collection
Parameter(s):
- (string) $type
- throws:
Gumbo_Exception Implementation of:
[ Top ]private void _onload ( ) [line 300]Executes the callback function
This method must be called by all methods inside the Collection. This will ensure that the Collection is populated only when the data it holds is needed.
- throws:
Gumbo_Exception - precondition:
getCallback () - precondition:
!isLoaded ()
[ Top ]public mixed __get ( int|string $key ) [line 77]Returns Data (wrapper to get())
Parameter(s):
- (int|string) $key :: for integers, use $list->{$num}
Implementation of:
[ Top ]public bool __isset ( int|string $key ) [line 95]Returns if key is set (wrapper to exists())
Parameter(s):
- (int|string) $key
Implementation of:
[ Top ]public void __set ( int|string $key, mixed $data ) [line 86]Sets Data (wrapper to add())
Parameter(s):
- (int|string) $key
- (mixed) $data
Implementation of:
[ Top ]