Code Duplication    Length = 19-28 lines in 2 locations

src/Arrayy.php 2 locations

@@ 1066-1084 (lines=19) @@
1063
     * @psalm-return static<TKey,T>
1064
     * @psalm-mutation-free
1065
     */
1066
    public function appendToEachValue($prefix): self
1067
    {
1068
        // init
1069
        $result = [];
1070
1071
        foreach ($this->getGenerator() as $key => $item) {
1072
            if ($item instanceof self) {
1073
                $result[$key] = $item->appendToEachValue($prefix);
1074
            } elseif (\is_array($item)) {
1075
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
1076
            } elseif (\is_object($item) === true) {
1077
                $result[$key] = $item;
1078
            } else {
1079
                $result[$key] = $prefix . $item;
1080
            }
1081
        }
1082
1083
        return self::create($result, $this->iteratorClass, false);
1084
    }
1085
1086
    /**
1087
     * Sort an array in reverse order and maintain index association.
@@ 4688-4715 (lines=28) @@
4685
     * @psalm-return static<TKey,T>
4686
     * @psalm-mutation-free
4687
     */
4688
    public function prependToEachValue($suffix): self
4689
    {
4690
        // init
4691
        $result = [];
4692
4693
        foreach ($this->getGenerator() as $key => $item) {
4694
            if ($item instanceof self) {
4695
                $result[$key] = $item->prependToEachValue($suffix);
4696
            } elseif (\is_array($item)) {
4697
                $result[$key] = self::create(
4698
                    $item,
4699
                    $this->iteratorClass,
4700
                    false
4701
                )->prependToEachValue($suffix)
4702
                    ->toArray();
4703
            } elseif (\is_object($item) === true) {
4704
                $result[$key] = $item;
4705
            } else {
4706
                $result[$key] = $item . $suffix;
4707
            }
4708
        }
4709
4710
        return self::create(
4711
            $result,
4712
            $this->iteratorClass,
4713
            false
4714
        );
4715
    }
4716
4717
    /**
4718
     * Return the value of a given key and