Code Duplication    Length = 17-19 lines in 2 locations

src/Arrayy.php 2 locations

@@ 1035-1053 (lines=19) @@
1032
     * @psalm-return static<TKey,T>
1033
     * @psalm-mutation-free
1034
     */
1035
    public function appendToEachKey($prefix): self
1036
    {
1037
        // init
1038
        $result = [];
1039
1040
        foreach ($this->getGenerator() as $key => $item) {
1041
            if ($item instanceof self) {
1042
                $result[$prefix . $key] = $item->appendToEachKey($prefix);
1043
            } elseif (\is_array($item)) {
1044
                $result[$prefix . $key] = self::create($item, $this->iteratorClass, false)
1045
                    ->appendToEachKey($prefix)
1046
                    ->toArray();
1047
            } else {
1048
                $result[$prefix . $key] = $item;
1049
            }
1050
        }
1051
1052
        return self::create($result, $this->iteratorClass, false);
1053
    }
1054
1055
    /**
1056
     * Add a prefix to each value.
@@ 4665-4681 (lines=17) @@
4662
     * @psalm-return static<TKey,T>
4663
     * @psalm-mutation-free
4664
     */
4665
    public function prependToEachKey($suffix): self
4666
    {
4667
        // init
4668
        $result = [];
4669
4670
        foreach ($this->getGenerator() as $key => $item) {
4671
            if ($item instanceof self) {
4672
                $result[$key] = $item->prependToEachKey($suffix);
4673
            } elseif (\is_array($item)) {
4674
                $result[$key] = self::create(
4675
                    $item,
4676
                    $this->iteratorClass,
4677
                    false
4678
                )->prependToEachKey($suffix)
4679
                    ->toArray();
4680
            } else {
4681
                $result[$key . $suffix] = $item;
4682
            }
4683
        }
4684