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
@@ 4931-4955 (lines=25) @@
4928
     * @phpstan-return static<TKey,T>
4929
     * @psalm-mutation-free
4930
     */
4931
    public function prependImmutable($value, $key = null)
4932
    {
4933
        $generator = function () use ($key, $value): \Generator {
4934
            if ($this->properties !== []) {
4935
                $this->checkType($key, $value);
4936
            }
4937
4938
            if ($key !== null) {
4939
                yield $key => $value;
4940
            } else {
4941
                yield $value;
4942
            }
4943
4944
            foreach ($this->getGenerator() as $keyOld => $itemOld) {
4945
                yield $keyOld => $itemOld;
4946
            }
4947
        };
4948
4949
        return static::create(
4950
            $generator,
4951
            $this->iteratorClass,
4952
            false
4953
        );
4954
    }
4955
4956
    /**
4957
     * Add a suffix to each key.
4958
     *