PVCollection

Implements \IteratorAggregate

The PVCollection class acts as a repository for data to be stored, retrieved and iterated over.

The collection class is a simple way of storing and getting information with key, value pairs, Any information can be stored and retrieved including strings, array, and objects. Some example use cases:

//Add data and increment over fit
$collection = new PVCollection();
$collection -> add('Apples');
$collection -> add('Oranges');

foreach($collection as $key => $value) {
    echo $value;
}
package

data

Methods

The constructor of this class takes in an array and passes it to the collection as the initial data.

__construct(array $data = array()) : void
access

public

Arguments

$data

array

An array of data

PHP magic function that returns an index if it is in the collection.

__get(string $index) : \$value
access

public

Arguments

$index

string

An index/key that will be used to find the value, if present

Response

\$value

The returned value if found in the index

Adds the passed data to an index in the collection that can be retrieved later.

add(mixed $data) : void
access

public

Arguments

$data

mixed

Passed data can be an array, object and any other value.

Adds a value to the collection but also defines the index/key in which the value will be placed at.

addWithName(string $name, mixed $data) : void
access

public

Arguments

$name

string

The name/index/key that will be associated with the passed value

$data

mixed

The data the will be story associated with thhat key.

Same as the magic function __get.

get(string $index) 
see \get

Arguments

$index

string

An index/key that will be used to find the value, if present

Returns all the data

getData() 

Returns an iterable object that can iteratered over in a loop.

getIterator() : \PVIterator
access

public

Response

\PVIterator

$iterable An iterable object

Remove a value from the collection based on the key/index.

remove(mixed $index) : void
access

public

Arguments

$index

mixed

The index can either be a int or string

Properties

The items stored in the collection, key=>value pair

dataset : 

Type(s)

The number of items in the collection

count : 

Type(s)