Code Duplication    Length = 15-24 lines in 5 locations

src/Arrayy.php 5 locations

@@ 3266-3289 (lines=24) @@
3263
     * @psalm-return static<TKey,T>
3264
     * @psalm-mutation-free
3265
     */
3266
    public function invoke($callable, $arguments = []): self
3267
    {
3268
        // If one argument given for each iteration, create an array for it.
3269
        if (\is_array($arguments) === false) {
3270
            $arguments = \array_fill(
3271
                0,
3272
                $this->count(),
3273
                $arguments
3274
            );
3275
        }
3276
3277
        // If the callable has arguments, pass them.
3278
        if ($arguments) {
3279
            $array = \array_map($callable, $this->toArray(), $arguments);
3280
        } else {
3281
            $array = $this->map($callable);
3282
        }
3283
3284
        return static::create(
3285
            $array,
3286
            $this->iteratorClass,
3287
            false
3288
        );
3289
    }
3290
3291
    /**
3292
     * Check whether array is associative or not.
@@ 3863-3877 (lines=15) @@
3860
     * @psalm-return static<int|TKey,T>
3861
     * @psalm-mutation-free
3862
     */
3863
    public function mergeAppendKeepIndex(array $array = [], bool $recursive = false): self
3864
    {
3865
        if ($recursive === true) {
3866
            $array = $this->getArrayRecursiveHelperArrayy($array);
3867
            $result = \array_replace_recursive($this->toArray(), $array);
3868
        } else {
3869
            $result = \array_replace($this->toArray(), $array);
3870
        }
3871
3872
        return static::create(
3873
            $result,
3874
            $this->iteratorClass,
3875
            false
3876
        );
3877
    }
3878
3879
    /**
3880
     * Merge the new $array into the current array.
@@ 3895-3909 (lines=15) @@
3892
     * @psalm-return static<TKey,T>
3893
     * @psalm-mutation-free
3894
     */
3895
    public function mergeAppendNewIndex(array $array = [], bool $recursive = false): self
3896
    {
3897
        if ($recursive === true) {
3898
            $array = $this->getArrayRecursiveHelperArrayy($array);
3899
            $result = \array_merge_recursive($this->toArray(), $array);
3900
        } else {
3901
            $result = \array_merge($this->toArray(), $array);
3902
        }
3903
3904
        return static::create(
3905
            $result,
3906
            $this->iteratorClass,
3907
            false
3908
        );
3909
    }
3910
3911
    /**
3912
     * Merge the the current array into the $array.
@@ 3926-3940 (lines=15) @@
3923
     * @psalm-return static<TKey,T>
3924
     * @psalm-mutation-free
3925
     */
3926
    public function mergePrependKeepIndex(array $array = [], bool $recursive = false): self
3927
    {
3928
        if ($recursive === true) {
3929
            $array = $this->getArrayRecursiveHelperArrayy($array);
3930
            $result = \array_replace_recursive($array, $this->toArray());
3931
        } else {
3932
            $result = \array_replace($array, $this->toArray());
3933
        }
3934
3935
        return static::create(
3936
            $result,
3937
            $this->iteratorClass,
3938
            false
3939
        );
3940
    }
3941
3942
    /**
3943
     * Merge the current array into the new $array.
@@ 3958-3972 (lines=15) @@
3955
     * @psalm-return static<TKey,T>
3956
     * @psalm-mutation-free
3957
     */
3958
    public function mergePrependNewIndex(array $array = [], bool $recursive = false): self
3959
    {
3960
        if ($recursive === true) {
3961
            $array = $this->getArrayRecursiveHelperArrayy($array);
3962
            $result = \array_merge_recursive($array, $this->toArray());
3963
        } else {
3964
            $result = \array_merge($array, $this->toArray());
3965
        }
3966
3967
        return static::create(
3968
            $result,
3969
            $this->iteratorClass,
3970
            false
3971
        );
3972
    }
3973
3974
    /**
3975
     * @return ArrayyMeta|static