Anemone::is()

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

Table of Contents
  1. Description
  2. Example

Description

Anemone::is(callable $fn, bool $keys = false): Anemone;

This is the OOP style of function is(), implemented as a class method. This method returns new Anemone instance contains items that have passed the test.

Example

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

$test = $anemone->is(function ($v) {
    return $v > 3;
});

test($test->get()); // Returns `[4, 5]`
test($test === $anemone); // Returns `false`
test($test->parent === $anemone); // Returns `true`

You call the Anemone::get() method to return raw array values, but you can also directly iterate over it.

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::pluck()

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