public function Collection::map

Same name in this branch

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

Parameters

\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:

Return value

Collection

File

drupal/core/vendor/guzzle/common/Guzzle/Common/Collection.php, line 225

Class

Collection
Key value pair collection object

Namespace

Guzzle\Common

Code

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;
}