Anemone::any()

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

Table of Contents
  1. Description
  2. Example

Description

Anemone::any(callable $fn): bool;
Anemone::any(mixed $value): bool;

This is the OOP style of function any(), implemented as a class method. It returns true if, in the data, it finds an item for which the provided function returns true, otherwise it returns false. It does not modify the data.

Example

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

if ($anemone->any(function ($v) {
    return 4 === $v;
})) {
    // There is at least one item in the `$anemone` with a value of `4`
}

For a simple return of value, you can summarize the call as in the example below:

if ($anemone->any(4)) {
    // There is at least one item in the `$anemone` with a value of `4`
}

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.