final class Collection implements Value, Countable, Iterator (View source)

A PHP representation of the CQL list datatype

Methods

__construct(Type $type)

Creates a new collection of a given type.

type()

The type of this collection.

array
values()

Array of values in this collection.

int
add(mixed ...$value)

Adds one or more values to this collection.

mixed
get(int $index)

Retrieves the value at a given index.

int
find(mixed $value)

Finds index of a value in this collection.

int<0, max>
count()

Total number of elements in this collection

TValue
current()

Current element for iteration

TKey|null
key()

Current key for iteration

void
next()

Move internal iterator forward

bool
valid()

Check whether a current value exists

void
rewind()

Rewind internal iterator

bool
remove(int $index)

Deletes the value at a given index

Details

__construct(Type $type)

Creates a new collection of a given type.

Parameters

Type $type

Type type()

The type of this collection.

Return Value

Type

array values()

Array of values in this collection.

Return Value

array values

int add(mixed ...$value)

Adds one or more values to this collection.

Parameters

mixed ...$value

one or more values to add

Return Value

int

total number of values in this collection

mixed get(int $index)

Retrieves the value at a given index.

Parameters

int $index Index

Return Value

mixed

Value or null

int find(mixed $value)

Finds index of a value in this collection.

Parameters

mixed $value Value

Return Value

int

Index or null

int<0, max> count()

Total number of elements in this collection

Return Value

int<0, max>

The custom count as an integer.

The return value is cast to an integer.

TValue current()

Current element for iteration

Return Value

TValue

Can return any type.

TKey|null key()

Current key for iteration

Return Value

TKey|null

TKey on success, or null on failure.

void next()

Move internal iterator forward

Return Value

void

Any returned value is ignored.

bool valid()

Check whether a current value exists

Return Value

bool

The return value will be casted to boolean and then evaluated. Returns true on success or false on failure.

void rewind()

Rewind internal iterator

Return Value

void

Any returned value is ignored.

bool remove(int $index)

Deletes the value at a given index

Parameters

int $index Index

Return Value

bool

Whether the value at a given index is correctly removed