\phpDocumentor\DescriptorCollection

Represents an easily accessible collection of elements.

The goal for this class is to allow Descriptors to be easily retrieved and set so that interaction in templates becomes easier.

Summary

Methods
Properties
Constants
__construct()
add()
set()
get()
getAll()
getIterator()
count()
clear()
__get()
offsetExists()
offsetGet()
offsetSet()
offsetUnset()
merge()
No public properties found
No constants found
No protected methods found
$items
N/A
No private methods found
No private properties found
N/A

Properties

$items

$items : array<mixed,mixed>

Type

array<mixed,mixed>

Methods

__construct()

__construct(array<mixed,\phpDocumentor\Descriptor\DescriptorAbstract>|array<mixed,mixed>  $items = array()) 

Constructs a new collection object with optionally a series of items, generally Descriptors.

Parameters

array<mixed,\phpDocumentor\Descriptor\DescriptorAbstract>|array<mixed,mixed> $items

set()

set(string|integer  $index, \phpDocumentor\Descriptor\DescriptorAbstract|mixed|null  $item) : void

Sets a new object onto the collection or clear it using null.

Parameters

string|integer $index

An index value to recognize this item with.

\phpDocumentor\Descriptor\DescriptorAbstract|mixed|null $item

The item to store, generally a Descriptor but may be something else.

get()

get(string|integer  $index, mixed  $valueIfEmpty = null) : mixed

Retrieves a specific item from the Collection with its index.

Please note that this method (intentionally) has the side effect that whenever a key does not exist that it will be created with the value provided by the $valueIfEmpty argument. This will allow for easy initialization during tree building operations.

Parameters

string|integer $index
mixed $valueIfEmpty

If the index does not exist it will be created with this value and returned.

Returns

mixed —

The contents of the element with the given index and the provided default if the key doesn't exist.

getAll()

getAll() : array<mixed,mixed>

Retrieves all items from this collection as PHP Array.

Returns

array<mixed,mixed>

getIterator()

getIterator() : \Traversable|\ArrayIterator

Retrieves an iterator to traverse this object.

Returns

\Traversable|\ArrayIterator

count()

count() : integer

Returns a count of the number of elements in this collection.

Returns

integer

clear()

clear() : void

Empties the collection.

__get()

__get(string  $name) : mixed

Retrieves an item as if it were a property of the collection.

Parameters

string $name

Returns

mixed

offsetExists()

offsetExists(string|integer  $offset) : boolean

Checks whether an item in this collection exists.

Parameters

string|integer $offset

The index to check on.

Returns

boolean

offsetGet()

offsetGet(string|integer  $offset) : mixed

Retrieves an item from the collection with the given index.

Parameters

string|integer $offset

The offset to retrieve.

Returns

mixed

offsetSet()

offsetSet(string|integer  $offset, mixed  $value) : void

Sets an item at the given index.

Parameters

string|integer $offset

The offset to assign the value to.

mixed $value

The value to set.

Throws

\InvalidArgumentException

if the key is null or an empty string.

offsetUnset()

offsetUnset(string|integer  $offset) : void

Removes an item with the given index from the collection.

Parameters

string|integer $offset

The offset to unset.