class Pair implements JsonSerializable (View source)

A pair is used by Ds\Map to pair keys with values.

Properties

TKey $key
TValue $value

Methods

__construct(TKey $key = null, TValue $value = null)

Creates a new instance using a given key and value.

clear()

Removes all values from the pair.

copy()

Returns a shallow copy of the pair.

bool
isEmpty()

Returns whether the pair is empty.

array
toArray()

Converts the pair to an array.

mixed
jsonSerialize()

Specify data which should be serialized to JSON

Details

__construct(TKey $key = null, TValue $value = null)

Creates a new instance using a given key and value.

Parameters

TKey $key
TValue $value

clear()

Removes all values from the pair.

Pair copy()

Returns a shallow copy of the pair.

Return Value

Pair

Returns a shallow copy of the pair.

bool isEmpty()

Returns whether the pair is empty.

Return Value

bool

Returns TRUE if the pair is empty, FALSE otherwise.

array toArray()

Converts the pair to an array.

Note: Casting to an array is not supported yet.

Return Value

array

mixed jsonSerialize()

Specify data which should be serialized to JSON

Return Value

mixed

data which can be serialized by json_encode, which is a value of any type other than a resource.