Ciconia / A New Markdown Parser for #PHP

class Collection implements IteratorAggregate, Countable

Methods

__construct(array $objects = array())

Constructor

Collection add(mixed $object)

Appends a new value as the last element.

Collection set(string $name, mixed $object)

Sets the value at the specified index

mixed get(string $name)

Returns the value at the specified index

bool exists(string $name)

Returns whether the requested index exists

bool contains(mixed $object)

Returns whether the requested value exists

Collection remove(string $name)

Remove

string join(string $glue = '')

Join array elements with a string

Collection slice(integer $offset, integer $length = null)

Extract a slice of the array

Collection each(callable $callable)

Execute the callback for each element

Collection apply(callable $callable)

Applies the callback to the elements

Collection filter(callable $callable = null)

Filters elements using a callback function

Traversable getIterator()

Retrieve an external iterator

int count()

Count elements of an object

Details

at line 21 public __construct(array $objects = array())

Constructor

Parameters

array $objects [optional]

at line 33 public Collection add(mixed $object)

Appends a new value as the last element.

Parameters

mixed $object The value to append

Return Value

Collection

at line 48 public Collection set(string $name, mixed $object)

Sets the value at the specified index

Parameters

string $name The index
mixed $object The value

Return Value

Collection

at line 64 public mixed get(string $name)

Returns the value at the specified index

Parameters

string $name The index

Return Value

mixed

Exceptions

OutOfBoundsException When the index is invalid

at line 80 public bool exists(string $name)

Returns whether the requested index exists

Parameters

string $name The index

Return Value

bool True if the index is valid

at line 92 public bool contains(mixed $object)

Returns whether the requested value exists

Parameters

mixed $object The value

Return Value

bool True if the value exists

at line 104 public Collection remove(string $name)

Remove

Parameters

string $name The index

Return Value

Collection

at line 120 public string join(string $glue = '')

Join array elements with a string

Parameters

string $glue [optional] Defaults to an empty string.

Return Value

string

at line 137 public Collection slice(integer $offset, integer $length = null)

Extract a slice of the array

Parameters

integer $offset If offset is non-negative, the sequence will start at that offset in the array. If offset is negative, the sequence will start that far from the end of the array.
integer $length If length is given and is positive, then the sequence will have up to that many elements in it. If the array is shorter than the length, then only the available array elements will be present. If length is given and is negative then the sequence will stop that many elements from the end of the array. If it is omitted, then the sequence will have everything from offset up until the end of the array.

Return Value

Collection

at line 149 public Collection each(callable $callable)

Execute the callback for each element

Parameters

callable $callable function ($value, $key) {}

Return Value

Collection

at line 167 public Collection apply(callable $callable)

Applies the callback to the elements

Parameters

callable $callable

Return Value

Collection

at line 181 public Collection filter(callable $callable = null)

Filters elements using a callback function

Parameters

callable $callable

Return Value

Collection

at line 191 public Traversable getIterator()

Retrieve an external iterator

Return Value

Traversable An instance of an object implementing Iterator or Traversable

at line 201 public int count()

Count elements of an object

Return Value

int The custom count as an integer. The return value is cast to an integer.