src/Bag.php
public function call(callable $callable, /*...*/$args = null)
    {
        // Optimized for no args. Argument unpacking is still faster once we get to use 5.6 syntax
        $result = $args ? call_user_func_array($callable, [$this->items] + func_get_args()) : $callable($this->items);
        // $result = $callable($this->items, ...$args);

        return $this->createFrom(Arr::from($result));
    }
public function call(callable $callable, /*...*/$args = null)
    {
        // Optimized for no args. Argument unpacking is still faster once we get to use 5.6 syntax
        $result = $args ? call_user_func_array($callable, [$this->items] + func_get_args()) : $callable($this->items);
        // $result = $callable($this->items, ...$args);

        return $this->createFrom(Arr::from($result));
    }
public function call ( callable $ callable , /*...*/ $ args = null ) { // Optimized for no args. Argument unpacking is still faster once we get to use 5.6 syntax $ result = $ args ? call_user_func_array ( $ callable , [ $ this -> items ] + func_get_args ( ) ) : $ callable ( $ this -> items ) ; // $result = $callable($this->items, ...$args); return $ this -> createFrom ( Arr :: from ( $ result ) ) ; }
Calls the `$callable` to modify the items.

This allows for chain-ability with custom functionality.

The `$callable` is given the bag's items (array) as the first parameter and should return an iterable which is
then converted to a bag. Any extra parameters passed in to this method are passed to the `$callable` after
the items parameter.

<br>
Example with closure:

Bag::from(['red', 'blue'])
->call(function (array $colors) {
$colors[] = 'green';

return $colors;
})
->join(', ');
// => "red, blue, green"

<br>
Example with function name and args:

Bag::from(['red', 'blue'])
->call('array_pad', 4, ''); // Assuming bag doesn't have a pad method ;)
// => Bag of ['red', 'blue', '', '']

@param callable $callable Function is given `($items, ...$args)` and should return an iterable
@param array    ...$args  Extra parameters to pass to the `$callable` after the items parameter

@return static
Calls the $callable to modify the items .