public function map(callable $callable, bool $useKeyAsSecondParameter = false, ...$arguments): self
    {
        $useArguments = \func_num_args() > 2;

        return static::create(
            function () use ($useArguments, $callable, $useKeyAsSecondParameter, $arguments) {
                foreach ($this->getGenerator() as $key => $value) {
                    if ($useArguments) {
                        if ($useKeyAsSecondParameter) {
                            yield $key => $callable($value, $key, ...$arguments);
                        } else {
                            yield $key => $callable($value, ...$arguments);
                        }
                    } else {
                        /** @noinspection NestedPositiveIfStatementsInspection */
                        if ($useKeyAsSecondParameter) {
                            yield $key => $callable($value, $key);
                        } else {
                            yield $key => $callable($value);
                        }
                    }
                }
            },
            $this->iteratorClass,
            false
        );
    }
public function map(callable $callable, bool $useKeyAsSecondParameter = false, ...$arguments): self
    {
        $useArguments = \func_num_args() > 2;

        return static::create(
            function () use ($useArguments, $callable, $useKeyAsSecondParameter, $arguments) {
                foreach ($this->getGenerator() as $key => $value) {
                    if ($useArguments) {
                        if ($useKeyAsSecondParameter) {
                            yield $key => $callable($value, $key, ...$arguments);
                        } else {
                            yield $key => $callable($value, ...$arguments);
                        }
                    } else {
                        /** @noinspection NestedPositiveIfStatementsInspection */
                        if ($useKeyAsSecondParameter) {
                            yield $key => $callable($value, $key);
                        } else {
                            yield $key => $callable($value);
                        }
                    }
                }
            },
            $this->iteratorClass,
            false
        );
    }
public function map ( callable $ callable , bool $ useKeyAsSecondParameter = false , ... $ arguments ) : self { $ useArguments = \ func_num_args ( ) > 2 ; return static :: create ( function ( ) use ( $ useArguments , $ callable , $ useKeyAsSecondParameter , $ arguments ) { foreach ( $ this -> getGenerator ( ) as $ key => $ value ) { if ( $ useArguments ) { if ( $ useKeyAsSecondParameter ) { yield $ key => $ callable ( $ value , $ key , ... $ arguments ) ; } else { yield $ key => $ callable ( $ value , ... $ arguments ) ; } } else { /** @noinspection NestedPositiveIfStatementsInspection */ if ( $ useKeyAsSecondParameter ) { yield $ key => $ callable ( $ value , $ key ) ; } else { yield $ key => $ callable ( $ value ) ; } } } } , $ this -> iteratorClass , false ) ; }
Apply the given function to the every element of the array,
collecting the results.

@param callable $callable
@param bool     $useKeyAsSecondParameter
@param mixed    ...$arguments

@return static
<p>(Immutable) Arrayy object with modified elements.</p>
Apply the given function to the every element of the array collecting the results .