Code Duplication    Length = 25-28 lines in 2 locations

src/Arrayy.php 2 locations

@@ 683-707 (lines=25) @@
680
         * @psalm-suppress PossiblyInvalidArgument
681
         * @psalm-suppress InvalidScalarArgument
682
         */
683
        if (
684
            $this->pathSeparator
685
            &&
686
            (string) $offset === $offset
687
            &&
688
            \strpos($offset, $this->pathSeparator) !== false
689
        ) {
690
            $explodedPath = \explode($this->pathSeparator, (string) $offset);
691
            if ($explodedPath !== false) {
692
                /** @var string $lastOffset - helper for phpstan */
693
                $lastOffset = \array_pop($explodedPath);
694
                $containerPath = \implode($this->pathSeparator, $explodedPath);
695
696
                /**
697
                 * @psalm-suppress MissingClosureReturnType
698
                 * @psalm-suppress MissingClosureParamType
699
                 */
700
                $this->callAtPath(
701
                    $containerPath,
702
                    static function ($container) use ($lastOffset, &$offsetExists) {
703
                        $offsetExists = \array_key_exists($lastOffset, $container);
704
                    }
705
                );
706
            }
707
        }
708
709
        return $offsetExists;
710
    }
@@ 787-814 (lines=28) @@
784
         * @psalm-suppress PossiblyInvalidArgument
785
         * @psalm-suppress InvalidScalarArgument
786
         */
787
        if (
788
            $this->pathSeparator
789
            &&
790
            (string) $offset === $offset
791
            &&
792
            \strpos($offset, $this->pathSeparator) !== false
793
        ) {
794
            $path = \explode($this->pathSeparator, (string) $offset);
795
796
            if ($path !== false) {
797
                $pathToUnset = \array_pop($path);
798
799
                /**
800
                 * @psalm-suppress MissingClosureReturnType
801
                 * @psalm-suppress MissingClosureParamType
802
                 */
803
                $this->callAtPath(
804
                    \implode($this->pathSeparator, $path),
805
                    static function (&$offset) use ($pathToUnset) {
806
                        if (\is_array($offset)) {
807
                            unset($offset[$pathToUnset]);
808
                        } else {
809
                            $offset = null;
810
                        }
811
                    }
812
                );
813
            }
814
        }
815
816
        unset($this->array[$offset]);
817
    }