Code Duplication    Length = 17-19 lines in 2 locations

src/Arrayy.php 2 locations

@@ 1043-1061 (lines=19) @@
1040
     * @psalm-return static<TKey,T>
1041
     * @psalm-mutation-free
1042
     */
1043
    public function appendToEachKey($prefix): self
1044
    {
1045
        // init
1046
        $result = [];
1047
1048
        foreach ($this->getGenerator() as $key => $item) {
1049
            if ($item instanceof self) {
1050
                $result[$prefix . $key] = $item->appendToEachKey($prefix);
1051
            } elseif (\is_array($item)) {
1052
                $result[$prefix . $key] = self::create($item, $this->iteratorClass, false)
1053
                    ->appendToEachKey($prefix)
1054
                    ->toArray();
1055
            } else {
1056
                $result[$prefix . $key] = $item;
1057
            }
1058
        }
1059
1060
        return self::create($result, $this->iteratorClass, false);
1061
    }
1062
1063
    /**
1064
     * Add a prefix to each value.
@@ 4784-4800 (lines=17) @@
4781
     * @psalm-return static<TKey,T>
4782
     * @psalm-mutation-free
4783
     */
4784
    public function prependToEachKey($suffix): self
4785
    {
4786
        // init
4787
        $result = [];
4788
4789
        foreach ($this->getGenerator() as $key => $item) {
4790
            if ($item instanceof self) {
4791
                $result[$key] = $item->prependToEachKey($suffix);
4792
            } elseif (\is_array($item)) {
4793
                $result[$key] = self::create(
4794
                    $item,
4795
                    $this->iteratorClass,
4796
                    false
4797
                )->prependToEachKey($suffix)
4798
                    ->toArray();
4799
            } else {
4800
                $result[$key . $suffix] = $item;
4801
            }
4802
        }
4803