Code Duplication    Length = 25-25 lines in 2 locations

src/Arrayy.php 2 locations

@@ 326-350 (lines=25) @@
323
     * @phpstan-return static<TKey,T>
324
     * @psalm-mutation-free
325
     */
326
    public function appendImmutable($value, $key = null): self
327
    {
328
        /**
329
         * @phpstan-return \Generator<TKey,T> $generator
330
         */
331
        $generator = function () use ($key, $value): \Generator {
332
            if ($this->properties !== []) {
333
                $this->checkType($key, $value);
334
            }
335
336
            foreach ($this->getGenerator() as $keyOld => $itemOld) {
337
                yield $keyOld => $itemOld;
338
            }
339
340
            if ($key !== null) {
341
                yield $key => $value;
342
            } else {
343
                yield $value;
344
            }
345
        };
346
347
        return static::create(
348
            $generator,
349
            $this->iteratorClass,
350
            false
351
        );
352
    }
353
@@ 4930-4954 (lines=25) @@
4927
     * @phpstan-return static<TKey,T>
4928
     * @psalm-mutation-free
4929
     */
4930
    public function prependImmutable($value, $key = null)
4931
    {
4932
        $generator = function () use ($key, $value): \Generator {
4933
            if ($this->properties !== []) {
4934
                $this->checkType($key, $value);
4935
            }
4936
4937
            if ($key !== null) {
4938
                yield $key => $value;
4939
            } else {
4940
                yield $value;
4941
            }
4942
4943
            foreach ($this->getGenerator() as $keyOld => $itemOld) {
4944
                yield $keyOld => $itemOld;
4945
            }
4946
        };
4947
4948
        return static::create(
4949
            $generator,
4950
            $this->iteratorClass,
4951
            false
4952
        );
4953
    }
4954
4955
    /**
4956
     * Add a suffix to each key.
4957
     *