Code Duplication    Length = 25-25 lines in 2 locations

src/Arrayy.php 2 locations

@@ 315-339 (lines=25) @@
312
     * @phpstan-return static<TKey,T>
313
     * @psalm-mutation-free
314
     */
315
    public function appendImmutable($value, $key = null): self
316
    {
317
        $generator = function () use ($key, $value): \Generator {
318
            if ($this->properties !== []) {
319
                $this->checkType($key, $value);
320
            }
321
322
            /** @noinspection YieldFromCanBeUsedInspection - FP */
323
            foreach ($this->getGenerator() as $keyOld => $itemOld) {
324
                yield $keyOld => $itemOld;
325
            }
326
327
            if ($key !== null) {
328
                yield $key => $value;
329
            } else {
330
                yield $value;
331
            }
332
        };
333
334
        return static::create(
335
            $generator,
336
            $this->iteratorClass,
337
            false
338
        );
339
    }
340
341
    /**
342
     * Sort the entries by value.
@@ 4898-4922 (lines=25) @@
4895
     * @phpstan-return static<TKey,T>
4896
     * @psalm-mutation-free
4897
     */
4898
    public function prependImmutable($value, $key = null)
4899
    {
4900
        $generator = function () use ($key, $value): \Generator {
4901
            if ($this->properties !== []) {
4902
                $this->checkType($key, $value);
4903
            }
4904
4905
            if ($key !== null) {
4906
                yield $key => $value;
4907
            } else {
4908
                yield $value;
4909
            }
4910
4911
            /** @noinspection YieldFromCanBeUsedInspection - FP */
4912
            foreach ($this->getGenerator() as $keyOld => $itemOld) {
4913
                yield $keyOld => $itemOld;
4914
            }
4915
        };
4916
4917
        return static::create(
4918
            $generator,
4919
            $this->iteratorClass,
4920
            false
4921
        );
4922
    }
4923
4924
    /**
4925
     * Add a suffix to each key.