trait ArrayAccessTrait

Encapsulates common logic for classes which implement the SPL \ArrayAccess interface.

Methods

offsetSet (string $offset, mixed $value)

Sets an internal key with a value.

offsetExists (string $offset) : bool

Checks whether an internal key exists.

offsetUnset (string $offset)

Unsets an internal key.

offsetGet (string $offset) : mixed|null

Retrieves an internal key.

Details

offsetSet(string $offset, mixed $value)

Sets an internal key with a value.

Parameters

$offset string
$value mixed

Example code

$arrayAccessTrait->offsetSet($offset, $value);

offsetExists(string $offset)

Checks whether an internal key exists.

Parameters

$offset string

Return value

bool

Example code

$bool = $arrayAccessTrait->offsetExists($offset);

offsetUnset(string $offset)

Unsets an internal key.

Parameters

$offset string

Example code

$arrayAccessTrait->offsetUnset($offset);

offsetGet(string $offset)

Retrieves an internal key.

Parameters

$offset string

Return value

mixed|null

Example code

$response = $arrayAccessTrait->offsetGet($offset);