Anemone::offsetGet()

Gets an item in the data using its key/index.

Table of Contents
  1. Description
  2. Example

Description

Anemone::offsetGet(mixed $key): mixed;

This method is a requirement to be able to implement the ArrayAccess interface and aims to make the object data accessible using array access syntax. You won’t use this method directly, it will be executed automatically when you try to get an item with array access syntax. This method gets an item in the data using its key/index. If the key/index does not exist in the data, this method returns null.

Example

$value = [1, 2, 3, 4, 5];
$anemone = new Anemone($value);

test($value[0]); // Returns `1`
test($anemone[0]); // Returns `1`
test($value[5]); // Undefined array key “5”
test($anemone[5]); // Returns `null`

Anemone::any()

Checks if at least one item in the data passes the test.

Anemone::is()

Filters the data so that only items that pass the test are left.

Anemone::not()

Filters the data so that only items that do not pass the test are left.

Anemone::offsetGet()

Gets an item in the data using its key/index.

Anemone::pluck()

Returns a new data set contains values from the key on every item.