public function map($closure)
    {
        $data = [];
        foreach ($this as $val) {
            $data[] = $closure($val);
        }
        return new Collection(compact('data'));
    }
public function map($closure)
    {
        $data = [];
        foreach ($this as $val) {
            $data[] = $closure($val);
        }
        return new Collection(compact('data'));
    }
public function map ( $ closure ) { $ data = [ ] ; foreach ( $ this as $ val ) { $ data [ ] = $ closure ( $ val ) ; } return new Collection ( compact ( 'data' ) ) ; }
Applies a closure to a copy of all data in the collection
and returns the result.

@param  Closure $closure The closure to apply.
@return mixed            Returns the set of filtered values inside a `Collection`.
Applies a closure to a copy of all data in the collection and returns the result .