Code Duplication    Length = 19-28 lines in 2 locations

src/Arrayy.php 2 locations

@@ 1069-1087 (lines=19) @@
1066
     * @psalm-return static<TKey,T>
1067
     * @psalm-mutation-free
1068
     */
1069
    public function appendToEachValue($prefix): self
1070
    {
1071
        // init
1072
        $result = [];
1073
1074
        foreach ($this->getGenerator() as $key => $item) {
1075
            if ($item instanceof self) {
1076
                $result[$key] = $item->appendToEachValue($prefix);
1077
            } elseif (\is_array($item)) {
1078
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
1079
            } elseif (\is_object($item) === true) {
1080
                $result[$key] = $item;
1081
            } else {
1082
                $result[$key] = $prefix . $item;
1083
            }
1084
        }
1085
1086
        return self::create($result, $this->iteratorClass, false);
1087
    }
1088
1089
    /**
1090
     * Sort an array in reverse order and maintain index association.
@@ 4858-4885 (lines=28) @@
4855
     * @psalm-return static<TKey,T>
4856
     * @psalm-mutation-free
4857
     */
4858
    public function prependToEachValue($suffix): self
4859
    {
4860
        // init
4861
        $result = [];
4862
4863
        foreach ($this->getGenerator() as $key => $item) {
4864
            if ($item instanceof self) {
4865
                $result[$key] = $item->prependToEachValue($suffix);
4866
            } elseif (\is_array($item)) {
4867
                $result[$key] = self::create(
4868
                    $item,
4869
                    $this->iteratorClass,
4870
                    false
4871
                )->prependToEachValue($suffix)
4872
                    ->toArray();
4873
            } elseif (\is_object($item) === true) {
4874
                $result[$key] = $item;
4875
            } else {
4876
                $result[$key] = $item . $suffix;
4877
            }
4878
        }
4879
4880
        return self::create(
4881
            $result,
4882
            $this->iteratorClass,
4883
            false
4884
        );
4885
    }
4886
4887
    /**
4888
     * Return the value of a given key and