Code Duplication    Length = 3-3 lines in 2 locations

src/Definition/Rules/ContainText.php 1 location

@@ 22-24 (lines=3) @@
19
20
    public function __construct($mode, Vars\Variable $var, $regexp) {
21
        parent::__construct($mode, $var);
22
        if (!is_string($regexp) || @preg_match("%$regexp%", "") === false) {
23
            throw new \InvalidArgumentException("Invalid regexp: '%regexp'");
24
        }
25
        $this->regexp = $regexp;
26
    }
27

src/Definition/Variables/WithName.php 1 location

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