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.
@@ 4703-4730 (lines=28) @@
4700
     * @psalm-return static<TKey,T>
4701
     * @psalm-mutation-free
4702
     */
4703
    public function prependToEachValue($suffix): self
4704
    {
4705
        // init
4706
        $result = [];
4707
4708
        foreach ($this->getGenerator() as $key => $item) {
4709
            if ($item instanceof self) {
4710
                $result[$key] = $item->prependToEachValue($suffix);
4711
            } elseif (\is_array($item)) {
4712
                $result[$key] = self::create(
4713
                    $item,
4714
                    $this->iteratorClass,
4715
                    false
4716
                )->prependToEachValue($suffix)
4717
                    ->toArray();
4718
            } elseif (\is_object($item) === true) {
4719
                $result[$key] = $item;
4720
            } else {
4721
                $result[$key] = $item . $suffix;
4722
            }
4723
        }
4724
4725
        return self::create(
4726
            $result,
4727
            $this->iteratorClass,
4728
            false
4729
        );
4730
    }
4731
4732
    /**
4733
     * Return the value of a given key and