Collections\Dictionary::map PHP Method

map() public method

public map ( callable $callable )
$callable callable
    public function map(callable $callable)
    {
        $items = [];
        $keyType = null;
        $valType = null;
        foreach ($this->storage as $key => $val) {
            list($k, $v) = $callable($key, $val);
            if (!isset($keyType) && !isset($valType)) {
                $keyType = gettype($k);
                $valType = gettype($v);
            }
            $items[$k] = $v;
        }
        return new static($keyType, $valType, $items);
    }