Code Duplication    Length = 11-17 lines in 4 locations

src/Context/PhpMatcher.php 4 locations

@@ 27-43 (lines=17) @@
24
    }
25
26
    /** @Then the response content should match :pattern */
27
    public function response_content_should_match(string $pattern)
28
    {
29
        $matcher = $this->factory->createMatcher();
30
        $content = (string) $this->getResponse()->getBody();
31
32
        if ($matcher->match($content, $pattern)) {
33
            return;
34
        }
35
36
        throw new InvalidArgumentException(
37
            sprintf(
38
                'The response does not match with the pattern "%s" (error : %s)',
39
                $pattern,
40
                $matcher->getError()
41
            )
42
        );
43
    }
44
45
    /** @Then the response content should not match :pattern */
46
    public function response_content_should_not_match(string $pattern)
@@ 46-62 (lines=17) @@
43
    }
44
45
    /** @Then the response content should not match :pattern */
46
    public function response_content_should_not_match(string $pattern)
47
    {
48
        $matcher = $this->factory->createMatcher();
49
        $content = (string) $this->getResponse()->getBody();
50
51
        if (!$matcher->match($content, $pattern)) {
52
            return;
53
        }
54
55
        throw new InvalidArgumentException(
56
            sprintf(
57
                'The response matches with the pattern "%s" (error : %s)',
58
                $pattern,
59
                $matcher->getError()
60
            )
61
        );
62
    }
63
64
    /** @Then the response content should match: */
65
    public function response_content_should_match_PyString(PyStringNode $pattern)
@@ 65-75 (lines=11) @@
62
    }
63
64
    /** @Then the response content should match: */
65
    public function response_content_should_match_PyString(PyStringNode $pattern)
66
    {
67
        $matcher = $this->factory->createMatcher();
68
        $content = (string) $this->getResponse()->getBody();
69
70
        if ($matcher->match($content, $pattern)) {
71
            return;
72
        }
73
74
        throw new InvalidArgumentException($matcher->getError());
75
    }
76
77
    /** @Then the response content should match: */
78
    public function response_content_should_not_match_PyString(PyStringNode $pattern)
@@ 78-88 (lines=11) @@
75
    }
76
77
    /** @Then the response content should match: */
78
    public function response_content_should_not_match_PyString(PyStringNode $pattern)
79
    {
80
        $matcher = $this->factory->createMatcher();
81
        $content = (string) $this->getResponse()->getBody();
82
83
        if (!$matcher->match($content, $pattern)) {
84
            return;
85
        }
86
87
        throw new InvalidArgumentException($matcher->getError());
88
    }
89
}
90