Anemone::__invoke()
Proxy for the current object, called as a function.
Table of Contents
Description
Anemone::__invoke(string $join = ', ', bool $filter = true): string;
Anemone::__invoke(string $join = ', ', callable $filter): string;
This method will be called when an Anemone
instance is called as a function. This method will convert the data into a string by ignoring data that cannot be converted into a string, and ignoring data that has a value of false
or null
, and data that has a key with prefix _
.
Example
$anemone = new Anemone([
'a' => 1,
'b' => 2,
'c' => 3,
'd' => [1, 2, 3],
'e' => false,
'f' => null,
'g' => new class {
public function __toString() {
return '###';
}
}
]);
$test = $anemone(', '); // Returns `'1, 2, 3, ###'`
You can also implement a filter to return the desired values:
$test = $anemone(', ', function ($key, $value) {
return is_string($value) && !str_starts_with($key, '#');
});
Anemone::_()
The dynamic method initiator.
Anemone::__call()
Proxy for missing methods.
Anemone::__callStatic()
Proxy for missing static methods.
Anemone::__construct()
The constructor.
Anemone::__destruct()
The desctructor.
Anemone::__get()
Proxy for missing properties.
Anemone::__invoke()
Proxy for the current object, called as a function.
Anemone::__serialize()
Provides data to be serialized.
Anemone::__toString()
Proxy for the current object, casted as a string.
Anemone::__unserialize()
Converts the serialized data back to its object.
Anemone::all()
Checks if all items in the data pass the test.
Anemone::any()
Checks if at least one item in the data passes the test.
Anemone::chunk()
Splits the data into chunks.
Anemone::count()
Counts the amount of data.
Anemone::find()
Returns the first item in the data that passes the test.
Anemone::first()
Returns the first item in the data.
Anemone::from()
Object instantiator.
Anemone::get()
Gets value recursively.
Anemone::getIterator()
The external iterator receiver.
Anemone::has()
Checks for the existence of a key recursively.
Anemone::index()
Gets item position index in the data by key.
Anemone::is()
Filters the data so that only items that pass the test are left.
Anemone::join()
Joins the data into a string.
Anemone::jsonSerialize()
Returns the data to be serialized as JSON.
Anemone::key()
Gets item key in data by position index.
Anemone::last()
Returns the last item in the data.
Anemone::let()
Deletes value recursively.
Anemone::map()
Creates a new data set from the current data.
Anemone::mitose()
Creates a new instance without reference it to a variable.
Anemone::not()
Filters the data so that only items that do not pass the test are left.
Anemone::offsetExists()
Checks if an item with a certain key/index exists in the data.
Anemone::offsetGet()
Gets an item in the data using its key/index.
Anemone::offsetSet()
Sets a value to the specified key/index in the data.
Anemone::offsetUnset()
Deletes an item at the specified key/index in the data.
Anemone::pluck()
Returns a new data set contains values from the key on every item.
Anemone::reverse()
Reverses the order of the data.
Anemone::set()
Sets value recursively.
Anemone::shake()
Shakes the order of the data.
Anemone::sort()
Sorts the data.