Code Duplication    Length = 3-4 lines in 2 locations

src/Rules/ContainText.php 1 location

@@ 37-40 (lines=4) @@
34
                "One argument is required when using a contain text.");
35
        }
36
        $regexp = $arguments[0];
37
        if (!is_string($regexp) || @preg_match("%$regexp%", "") === false) {
38
            throw new \InvalidArgumentException(
39
                "Invalid regexp '$regexp' when using contain text.");
40
        }
41
    }
42
43
    /**

src/Variables/WithName.php 1 location

@@ 31-33 (lines=3) @@
28
29
    public function __construct($regexp, Variable $other) {
30
        parent::__construct($other->name());
31
        if (!is_string($regexp) || @preg_match("%$regexp%", "") === false) {
32
            throw new \InvalidArgumentException("Invalid regexp: '%$regexp%'");
33
        }
34
        $this->regexp = $regexp;
35
        $this->other = $other;
36
    }