Code Duplication    Length = 15-24 lines in 5 locations

src/Arrayy.php 5 locations

@@ 3260-3283 (lines=24) @@
3257
     * @psalm-return static<TKey,T>
3258
     * @psalm-mutation-free
3259
     */
3260
    public function invoke($callable, $arguments = []): self
3261
    {
3262
        // If one argument given for each iteration, create an array for it.
3263
        if (\is_array($arguments) === false) {
3264
            $arguments = \array_fill(
3265
                0,
3266
                $this->count(),
3267
                $arguments
3268
            );
3269
        }
3270
3271
        // If the callable has arguments, pass them.
3272
        if ($arguments) {
3273
            $array = \array_map($callable, $this->toArray(), $arguments);
3274
        } else {
3275
            $array = $this->map($callable);
3276
        }
3277
3278
        return static::create(
3279
            $array,
3280
            $this->iteratorClass,
3281
            false
3282
        );
3283
    }
3284
3285
    /**
3286
     * Check whether array is associative or not.
@@ 3857-3871 (lines=15) @@
3854
     * @psalm-return static<int|TKey,T>
3855
     * @psalm-mutation-free
3856
     */
3857
    public function mergeAppendKeepIndex(array $array = [], bool $recursive = false): self
3858
    {
3859
        if ($recursive === true) {
3860
            $array = $this->getArrayRecursiveHelperArrayy($array);
3861
            $result = \array_replace_recursive($this->toArray(), $array);
3862
        } else {
3863
            $result = \array_replace($this->toArray(), $array);
3864
        }
3865
3866
        return static::create(
3867
            $result,
3868
            $this->iteratorClass,
3869
            false
3870
        );
3871
    }
3872
3873
    /**
3874
     * Merge the new $array into the current array.
@@ 3889-3903 (lines=15) @@
3886
     * @psalm-return static<TKey,T>
3887
     * @psalm-mutation-free
3888
     */
3889
    public function mergeAppendNewIndex(array $array = [], bool $recursive = false): self
3890
    {
3891
        if ($recursive === true) {
3892
            $array = $this->getArrayRecursiveHelperArrayy($array);
3893
            $result = \array_merge_recursive($this->toArray(), $array);
3894
        } else {
3895
            $result = \array_merge($this->toArray(), $array);
3896
        }
3897
3898
        return static::create(
3899
            $result,
3900
            $this->iteratorClass,
3901
            false
3902
        );
3903
    }
3904
3905
    /**
3906
     * Merge the the current array into the $array.
@@ 3920-3934 (lines=15) @@
3917
     * @psalm-return static<TKey,T>
3918
     * @psalm-mutation-free
3919
     */
3920
    public function mergePrependKeepIndex(array $array = [], bool $recursive = false): self
3921
    {
3922
        if ($recursive === true) {
3923
            $array = $this->getArrayRecursiveHelperArrayy($array);
3924
            $result = \array_replace_recursive($array, $this->toArray());
3925
        } else {
3926
            $result = \array_replace($array, $this->toArray());
3927
        }
3928
3929
        return static::create(
3930
            $result,
3931
            $this->iteratorClass,
3932
            false
3933
        );
3934
    }
3935
3936
    /**
3937
     * Merge the current array into the new $array.
@@ 3952-3966 (lines=15) @@
3949
     * @psalm-return static<TKey,T>
3950
     * @psalm-mutation-free
3951
     */
3952
    public function mergePrependNewIndex(array $array = [], bool $recursive = false): self
3953
    {
3954
        if ($recursive === true) {
3955
            $array = $this->getArrayRecursiveHelperArrayy($array);
3956
            $result = \array_merge_recursive($array, $this->toArray());
3957
        } else {
3958
            $result = \array_merge($array, $this->toArray());
3959
        }
3960
3961
        return static::create(
3962
            $result,
3963
            $this->iteratorClass,
3964
            false
3965
        );
3966
    }
3967
3968
    /**
3969
     * @return ArrayyMeta|static