Code Duplication    Length = 25-28 lines in 2 locations

src/Arrayy.php 2 locations

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