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.
@@ 2879-2899 (lines=21) @@
2876
     * @return static
2877
     *                <p>(Immutable) Return an Arrayy object, with the prepended values.</p>
2878
     */
2879
    public function prependToEachValue($suffix): self
2880
    {
2881
        // init
2882
        $result = [];
2883
2884
        foreach ($this->getGenerator() as $key => $item) {
2885
            if ($item instanceof self) {
2886
                $result[$key] = $item->prependToEachValue($suffix);
2887
            } elseif (\is_array($item)) {
2888
                $result[$key] = self::create(
2889
                    $item,
2890
                    $this->iteratorClass,
2891
                    false
2892
                )->prependToEachValue($suffix)
2893
                    ->toArray();
2894
            } elseif (\is_object($item)) {
2895
                $result[$key] = $item;
2896
            } else {
2897
                $result[$key] = $item . $suffix;
2898
            }
2899
        }
2900
2901
        return self::create(
2902
            $result,