Code Duplication    Length = 19-21 lines in 2 locations

src/Arrayy.php 2 locations

@@ 715-733 (lines=19) @@
712
     * @return static
713
     *                <p>(Immutable) Return an Arrayy object, with the prefixed values.</p>
714
     */
715
    public function appendToEachValue($prefix): self
716
    {
717
        // init
718
        $result = [];
719
720
        foreach ($this->getGenerator() as $key => $item) {
721
            if ($item instanceof self) {
722
                $result[$key] = $item->appendToEachValue($prefix);
723
            } elseif (\is_array($item)) {
724
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
725
            } elseif (\is_object($item)) {
726
                $result[$key] = $item;
727
            } else {
728
                $result[$key] = $prefix . $item;
729
            }
730
        }
731
732
        return self::create($result, $this->iteratorClass, false);
733
    }
734
735
    /**
736
     * Sort an array in reverse order and maintain index association.
@@ 3120-3140 (lines=21) @@
3117
     * @return static
3118
     *                <p>(Immutable) Return an Arrayy object, with the prepended values.</p>
3119
     */
3120
    public function prependToEachValue($suffix): self
3121
    {
3122
        // init
3123
        $result = [];
3124
3125
        foreach ($this->getGenerator() as $key => $item) {
3126
            if ($item instanceof self) {
3127
                $result[$key] = $item->prependToEachValue($suffix);
3128
            } elseif (\is_array($item)) {
3129
                $result[$key] = self::create(
3130
                    $item,
3131
                    $this->iteratorClass,
3132
                    false
3133
                )->prependToEachValue($suffix)
3134
                    ->toArray();
3135
            } elseif (\is_object($item)) {
3136
                $result[$key] = $item;
3137
            } else {
3138
                $result[$key] = $item . $suffix;
3139
            }
3140
        }
3141
3142
        return self::create(
3143
            $result,