Code Duplication    Length = 25-28 lines in 2 locations

src/Arrayy.php 2 locations

@@ 628-652 (lines=25) @@
625
         * @psalm-suppress PossiblyInvalidArgument
626
         * @psalm-suppress InvalidScalarArgument
627
         */
628
        if (
629
            $this->pathSeparator
630
            &&
631
            (string) $offset === $offset
632
            &&
633
            \strpos($offset, $this->pathSeparator) !== false
634
        ) {
635
            $explodedPath = \explode($this->pathSeparator, (string) $offset);
636
            if ($explodedPath !== false) {
637
                /** @var string $lastOffset - helper for phpstan */
638
                $lastOffset = \array_pop($explodedPath);
639
                $containerPath = \implode($this->pathSeparator, $explodedPath);
640
641
                /**
642
                 * @psalm-suppress MissingClosureReturnType
643
                 * @psalm-suppress MissingClosureParamType
644
                 */
645
                $this->callAtPath(
646
                    $containerPath,
647
                    static function ($container) use ($lastOffset, &$offsetExists) {
648
                        $offsetExists = \array_key_exists($lastOffset, $container);
649
                    }
650
                );
651
            }
652
        }
653
654
        return $offsetExists;
655
    }
@@ 732-759 (lines=28) @@
729
         * @psalm-suppress PossiblyInvalidArgument
730
         * @psalm-suppress InvalidScalarArgument
731
         */
732
        if (
733
            $this->pathSeparator
734
            &&
735
            (string) $offset === $offset
736
            &&
737
            \strpos($offset, $this->pathSeparator) !== false
738
        ) {
739
            $path = \explode($this->pathSeparator, (string) $offset);
740
741
            if ($path !== false) {
742
                $pathToUnset = \array_pop($path);
743
744
                /**
745
                 * @psalm-suppress MissingClosureReturnType
746
                 * @psalm-suppress MissingClosureParamType
747
                 */
748
                $this->callAtPath(
749
                    \implode($this->pathSeparator, $path),
750
                    static function (&$offset) use ($pathToUnset) {
751
                        if (\is_array($offset)) {
752
                            unset($offset[$pathToUnset]);
753
                        } else {
754
                            $offset = null;
755
                        }
756
                    }
757
                );
758
            }
759
        }
760
761
        unset($this->array[$offset]);
762
    }