Anemone::set()

Sets value recursively.

Table of Contents
  1. Description
  2. Example

Description

Anemone::set(array $values): array;
Anemone::set(string $key, mixed $value): array;

Sets value recursively using dot notation syntax. This is the OOP style of function set(), implemented as a class method. This method returns data on the access location.

Example

$anemone = new Anemone([
    'foo' => 1,
    'bar' => [
        'baz' => 2,
        'qux' => 3
    ]
]);

$foo = $anemone->set('foo', '#'); // Returns `['foo' => '#', 'bar' => ['baz' => 2, 'qux' => 3]]`
$baz = $anemone->set('bar.baz', '#'); // Returns `['baz' => '#', 'qux' => 3]`
$wut = $anemone->set('bar.wut', '#'); // Returns `['baz' => '#', 'qux' => 3, 'wut' => '#']`
$wut = $anemone->set('bar.wut'); // Returns `['baz' => '#', 'qux' => 3, 'wut' => null]`

test($anemone->get()); // Returns `['foo' => '#', 'bar' => ['baz' => '#', 'qux' => 3, 'wut' => null]]`

$all = $anemone->set(['foo' => 1]); // Returns `['foo' => 1]`

test($anemone->get()); // Returns `['foo' => 1]`

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.

Anemone::set()

Sets value recursively.