Collections\Collection::map PHP Method

map() public method

public map ( callable $callable )
$callable callable
    public function map(callable $callable)
    {
        $items = [];
        $type = null;
        foreach ($this->items as $item) {
            $result = $callable($item);
            if (!isset($type)) {
                $type = gettype($result);
                if ($type === "object") {
                    $type = get_class($result);
                }
            }
            $items[] = $result;
        }
        $col = new static($type);
        $col->setItemsFromTrustedSource($items);
        return $col;
    }