Code Duplication    Length = 10-12 lines in 2 locations

src/SilverStripe/BehatExtension/Context/BasicContext.php 2 locations

@@ 755-764 (lines=10) @@
752
        $regex  = '/'.preg_quote($text, '/').'/ui';
753
754
        if (trim($negate)) {
755
            if (preg_match($regex, $actual)) {
756
                $message = sprintf(
757
                    'The text "%s" was found in the text of the "%s" region on the page %s.',
758
                    $text,
759
                    $region,
760
                    $this->getSession()->getCurrentUrl()
761
                );
762
763
                throw new \Exception($message);
764
            }
765
        } else {
766
            if (!preg_match($regex, $actual)) {
767
                $message = sprintf(
@@ 765-776 (lines=12) @@
762
763
                throw new \Exception($message);
764
            }
765
        } else {
766
            if (!preg_match($regex, $actual)) {
767
                $message = sprintf(
768
                    'The text "%s" was not found anywhere in the text of the "%s" region on the page %s.',
769
                    $text,
770
                    $region,
771
                    $this->getSession()->getCurrentUrl()
772
                );
773
774
                throw new \Exception($message);
775
            }
776
        }
777
    }
778
779
    /**