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:

Class Variables

string|array $_callback [line 43]
array $_list = array () [line 40]
bool $_loaded =  false [line 47]
array $_params = array () [line 45]
string $_type =  "StdClass" [line 38]

Class Methods

public Gumbo_Collection __construct ( [string $func], [string|StdClass $cls] ) [line 56]

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 ]
public void add ( $data, [string|int $key], StdClass $obj ) [line 116]

Adds an Object to the Collection

Parameter(s):

  • (StdClass) $obj
  • (string|int) $key :: key reference name
  • () $data
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_List::add()

[ Top ]
public bool exists ( int|string $key ) [line 378]

Verifies a Key exists

Parameter(s):

  • (int|string) $key
Implementation of:
Gumbo_Interface_List::exists()

[ 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:
Gumbo_Interface_List::get()

[ Top ]
public array getAll ( ) [line 358]

Returns the entire List

Implementation of:
Gumbo_Interface_List::getAll()

[ Top ]
public string|array getCallback ( ) [line 421]

Returns the callback function/method

Implementation of:
Gumbo_Interface_Collection::getCallback()

[ Top ]
public Gumbo_Iterator getIterator ( ) [line 448]

Returns an Iterator object

Implementation of:
IteratorAggregate::getIterator

[ Top ]
public array getParams ( ) [line 429]

Returns the parameters to pass to the callback

Implementation of:
Gumbo_Interface_Collection::getParams()

[ Top ]
public string getType ( ) [line 413]

Returns the Collection Type

Implementation of:
Gumbo_Interface_Collection::getType()

[ Top ]
public bool isLoaded ( ) [line 437]

Returns if the Collection has been loaded

Implementation of:
Gumbo_Interface_Collection::isLoaded()

[ Top ]
public array keys ( ) [line 367]

Returns an array of the Collection keys

  • precondition:  size () > 0
Implementation of:
Gumbo_Interface_List::keys()

[ 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:
Gumbo_Interface_List::remove()

[ Top ]
public void removeValue ( mixed $data ) [line 180]

Removes a value from the List (not used)

Parameter(s):

  • (mixed) $data
Implementation of:
Gumbo_Interface_List::removeValue()

[ Top ]
public void reset ( ) [line 188]

Resets the List (not used)

  • postcondition:  !size()
Implementation of:
Gumbo_Interface_List::reset()

[ 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:

  1. $coll->setCallback ("function_name");

To set a class/object method (3 methods):

  1.  $col->setCallback ("method_name""class_name");
  2.  // 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:
Gumbo_Interface_Collection::setCallback()

[ 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:
Gumbo_Interface_Collection::setType()

[ Top ]
public int size ( ) [line 401]

Returns the size of the Collection

Implementation of:
Gumbo_Interface_List::size()

[ 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:
Gumbo_Interface_List::__get()

[ Top ]
public bool __isset ( int|string $key ) [line 95]

Returns if key is set (wrapper to exists())

Parameter(s):

  • (int|string) $key
Implementation of:
Gumbo_Interface_List::__isset()

[ 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:
Gumbo_Interface_List::__set()

[ Top ]
public void __unset ( int|string $key ) [line 103]

Removes Data (wrapper to remove())

Parameter(s):

  • (int|string) $key
Implementation of:
Gumbo_Interface_List::__unset()

[ Top ]