The PxWrappedCollection Class
PxWrappedCollection: A collection for wrapped objects
You can wrap this collection around something else (for example an array or an other collection) to ensure
that you have an object the implements the PxCollection interface.
When you loop through the collection, this object makes sure you are in fact looping over the underlying
wrapped collection.
that you have an object the implements the PxCollection interface.
When you loop through the collection, this object makes sure you are in fact looping over the underlying
wrapped collection.
Synopsis
Class PxWrappedCollection implements PxCollection, ArrayAccess, Countable, Traversable, IteratorAggregate
Properties
Methods
Examples
Example
How to use the PxWrappedCollection
// Return the number of fibonacci
function fibonacci($integer)
{
if ($integer == 1 || $integer == 2) return 1;
return fibonacci($integer - 1) + fibonacci($integer - 2);
}
// create the PxWrappedCollection with the integers and the fibonacci callback
$collection = new PxWrappedCollection(array(1,3,6,9,12), 'fibonacci');
// display the fibonacci numbers of the collection
foreach ($collection as $f) var_dump($f);
int(1) int(2) int(8) int(34) int(144)
