Code Duplication    Length = 19-21 lines in 2 locations

src/Arrayy.php 2 locations

@@ 721-739 (lines=19) @@
718
     * @return static
719
     *                <p>(Immutable) Return an Arrayy object, with the prefixed values.</p>
720
     */
721
    public function appendToEachValue($prefix): self
722
    {
723
        // init
724
        $result = [];
725
726
        foreach ($this->getGenerator() as $key => $item) {
727
            if ($item instanceof self) {
728
                $result[$key] = $item->appendToEachValue($prefix);
729
            } elseif (\is_array($item)) {
730
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
731
            } elseif (\is_object($item)) {
732
                $result[$key] = $item;
733
            } else {
734
                $result[$key] = $prefix . $item;
735
            }
736
        }
737
738
        return self::create($result, $this->iteratorClass, false);
739
    }
740
741
    /**
742
     * Sort an array in reverse order and maintain index association.
@@ 2930-2950 (lines=21) @@
2927
     * @return static
2928
     *                <p>(Immutable) Return an Arrayy object, with the prepended values.</p>
2929
     */
2930
    public function prependToEachValue($suffix): self
2931
    {
2932
        // init
2933
        $result = [];
2934
2935
        foreach ($this->getGenerator() as $key => $item) {
2936
            if ($item instanceof self) {
2937
                $result[$key] = $item->prependToEachValue($suffix);
2938
            } elseif (\is_array($item)) {
2939
                $result[$key] = self::create(
2940
                    $item,
2941
                    $this->iteratorClass,
2942
                    false
2943
                )->prependToEachValue($suffix)
2944
                    ->toArray();
2945
            } elseif (\is_object($item)) {
2946
                $result[$key] = $item;
2947
            } else {
2948
                $result[$key] = $item . $suffix;
2949
            }
2950
        }
2951
2952
        return self::create(
2953
            $result,