final class Map implements Value, Countable, Iterator, ArrayAccess (View source)

A PHP representation of the CQL map datatype

Methods

__construct(Type $keyType, Type $valueType)

Creates a new map of a given key and value type.

type()

The type of this map.

array
keys()

Returns all keys in the map as an array.

array
values()

Returns all values in the map as an array.

mixed
set(mixed $key, mixed $value)

Sets key/value in the map.

mixed
get(mixed $key)

Gets the value of the key in the map.

bool
remove(mixed $key)

Removes the key from the map.

bool
has(mixed $key)

Returns whether the key is in the map.

int
count()

Total number of elements in this map

mixed
current()

Current value for iteration

mixed
key()

Current key for iteration

void
next()

Move internal iterator forward

bool
valid()

Check whether a current value exists

void
rewind()

Rewind internal iterator

void
offsetSet(mixed $key, TValue $value)

Sets the value at a given key

mixed
offsetGet(mixed $key)

Retrieves the value at a given key

void
offsetUnset(mixed $key)

Deletes the value at a given key

bool
offsetExists(mixed $key)

Returns whether the value a given key is present

Details

__construct(Type $keyType, Type $valueType)

Creates a new map of a given key and value type.

Parameters

Type $keyType
Type $valueType

Type type()

The type of this map.

Return Value

Type

array keys()

Returns all keys in the map as an array.

Return Value

array keys

array values()

Returns all values in the map as an array.

Return Value

array values

mixed set(mixed $key, mixed $value)

Sets key/value in the map.

Parameters

mixed $key key
mixed $value value

Return Value

mixed

mixed get(mixed $key)

Gets the value of the key in the map.

Parameters

mixed $key Key

Return Value

mixed

Value or null

bool remove(mixed $key)

Removes the key from the map.

Parameters

mixed $key Key

Return Value

bool

Whether the key was removed or not, e.g. didn't exist

bool has(mixed $key)

Returns whether the key is in the map.

Parameters

mixed $key Key

Return Value

bool

Whether the key is in the map or not

int count()

Total number of elements in this map

Return Value

int

The custom count as an integer.

The return value is cast to an integer.

mixed current()

Current value for iteration

Return Value

mixed

Can return any type.

mixed key()

Current key for iteration

Return Value

mixed

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.

void offsetSet(mixed $key, TValue $value)

Sets the value at a given key

Parameters

mixed $key

Key to use.

TValue $value

The value to set.

Return Value

void

Exceptions

InvalidArgumentException

mixed offsetGet(mixed $key)

Retrieves the value at a given key

Parameters

mixed $key

Key to use.

Return Value

mixed

Can return all value types.

Exceptions

InvalidArgumentException

void offsetUnset(mixed $key)

Deletes the value at a given key

Parameters

mixed $key

Key to use.

Return Value

void

Exceptions

InvalidArgumentException

bool offsetExists(mixed $key)

Returns whether the value a given key is present

Parameters

mixed $key

Key to use.

Return Value

bool

true on success or false on failure.

The return value will be casted to boolean if non-boolean was returned.

Exceptions

InvalidArgumentException