Code Duplication    Length = 17-19 lines in 2 locations

src/Arrayy.php 2 locations

@@ 1038-1056 (lines=19) @@
1035
     * @psalm-return static<TKey,T>
1036
     * @psalm-mutation-free
1037
     */
1038
    public function appendToEachKey($prefix): self
1039
    {
1040
        // init
1041
        $result = [];
1042
1043
        foreach ($this->getGenerator() as $key => $item) {
1044
            if ($item instanceof self) {
1045
                $result[$prefix . $key] = $item->appendToEachKey($prefix);
1046
            } elseif (\is_array($item)) {
1047
                $result[$prefix . $key] = self::create($item, $this->iteratorClass, false)
1048
                    ->appendToEachKey($prefix)
1049
                    ->toArray();
1050
            } else {
1051
                $result[$prefix . $key] = $item;
1052
            }
1053
        }
1054
1055
        return self::create($result, $this->iteratorClass, false);
1056
    }
1057
1058
    /**
1059
     * Add a prefix to each value.
@@ 4820-4836 (lines=17) @@
4817
     * @psalm-return static<TKey,T>
4818
     * @psalm-mutation-free
4819
     */
4820
    public function prependToEachKey($suffix): self
4821
    {
4822
        // init
4823
        $result = [];
4824
4825
        foreach ($this->getGenerator() as $key => $item) {
4826
            if ($item instanceof self) {
4827
                $result[$key] = $item->prependToEachKey($suffix);
4828
            } elseif (\is_array($item)) {
4829
                $result[$key] = self::create(
4830
                    $item,
4831
                    $this->iteratorClass,
4832
                    false
4833
                )->prependToEachKey($suffix)
4834
                    ->toArray();
4835
            } else {
4836
                $result[$key . $suffix] = $item;
4837
            }
4838
        }
4839