Code Duplication    Length = 19-26 lines in 2 locations

src/Arrayy.php 2 locations

@@ 974-992 (lines=19) @@
971
     * @psalm-return static<TKey,T>
972
     * @psalm-mutation-free
973
     */
974
    public function appendToEachKey($prefix): self
975
    {
976
        // init
977
        $result = [];
978
979
        foreach ($this->getGenerator() as $key => $item) {
980
            if ($item instanceof self) {
981
                $result[$prefix . $key] = $item->appendToEachKey($prefix);
982
            } elseif (\is_array($item) === true) {
983
                $result[$prefix . $key] = self::create($item, $this->iteratorClass, false)
984
                    ->appendToEachKey($prefix)
985
                    ->toArray();
986
            } else {
987
                $result[$prefix . $key] = $item;
988
            }
989
        }
990
991
        return self::create($result, $this->iteratorClass, false);
992
    }
993
994
    /**
995
     * Add a prefix to each value.
@@ 4329-4354 (lines=26) @@
4326
     * @psalm-return static<TKey,T>
4327
     * @psalm-mutation-free
4328
     */
4329
    public function prependToEachKey($suffix): self
4330
    {
4331
        // init
4332
        $result = [];
4333
4334
        foreach ($this->getGenerator() as $key => $item) {
4335
            if ($item instanceof self) {
4336
                $result[$key] = $item->prependToEachKey($suffix);
4337
            } elseif (\is_array($item) === true) {
4338
                $result[$key] = self::create(
4339
                    $item,
4340
                    $this->iteratorClass,
4341
                    false
4342
                )->prependToEachKey($suffix)
4343
                    ->toArray();
4344
            } else {
4345
                $result[$key . $suffix] = $item;
4346
            }
4347
        }
4348
4349
        return self::create(
4350
            $result,
4351
            $this->iteratorClass,
4352
            false
4353
        );
4354
    }
4355
4356
    /**
4357
     * Add a suffix to each value.