Code Duplication    Length = 3-4 lines in 2 locations

src/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
    }

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
    /**