Code Duplication    Length = 19-26 lines in 2 locations

src/Arrayy.php 2 locations

@@ 709-727 (lines=19) @@
706
     * @return static
707
     *                <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p>
708
     */
709
    public function appendToEachKey($prefix): self
710
    {
711
        // init
712
        $result = [];
713
714
        foreach ($this->getGenerator() as $key => $item) {
715
            if ($item instanceof self) {
716
                $result[$prefix . $key] = $item->appendToEachKey($prefix);
717
            } elseif (\is_array($item) === true) {
718
                $result[$prefix . $key] = self::create($item, $this->iteratorClass, false)
719
                    ->appendToEachKey($prefix)
720
                    ->toArray();
721
            } else {
722
                $result[$prefix . $key] = $item;
723
            }
724
        }
725
726
        return self::create($result, $this->iteratorClass, false);
727
    }
728
729
    /**
730
     * Add a prefix to each value.
@@ 3326-3351 (lines=26) @@
3323
     * @return static
3324
     *                <p>(Immutable) Return an Arrayy object, with the prepended keys.</p>
3325
     */
3326
    public function prependToEachKey($suffix): self
3327
    {
3328
        // init
3329
        $result = [];
3330
3331
        foreach ($this->getGenerator() as $key => $item) {
3332
            if ($item instanceof self) {
3333
                $result[$key] = $item->prependToEachKey($suffix);
3334
            } elseif (\is_array($item) === true) {
3335
                $result[$key] = self::create(
3336
                    $item,
3337
                    $this->iteratorClass,
3338
                    false
3339
                )->prependToEachKey($suffix)
3340
                    ->toArray();
3341
            } else {
3342
                $result[$key . $suffix] = $item;
3343
            }
3344
        }
3345
3346
        return self::create(
3347
            $result,
3348
            $this->iteratorClass,
3349
            false
3350
        );
3351
    }
3352
3353
    /**
3354
     * Add a suffix to each value.