Returns a Collection containing all the elements of the collection after applying the callback function to each one. The Closure should accept three parameters: (string) $key, (string) $value, (array) $context and return a modified value
\Closure $closure Closure to apply:
array $context Context to pass to the closure:
bool $static Set to TRUE to use the same class as the return rather than returning a Collection:
public function map(\Closure $closure, array $context = array(), $static = true) {
$collection = $static ? new static() : new self();
foreach ($this as $key => $value) {
$collection
->add($key, $closure($key, $value, $context));
}
return $collection;
}