Code Duplication    Length = 20-20 lines in 2 locations

src/Rules/Html/StringExistsRule.php 1 location

@@ 11-30 (lines=20) @@
8
/**
9
 * This rule will analyze any html document and checks if a given string is contained.
10
 */
11
class StringExistsRule extends StandardRule
12
{
13
    private $string;
14
15
    protected $contentTypes = array('text/html');
16
17
    /**
18
     * @param int $string The string that the document must contain
19
     */
20
    public function init($string)
21
    {
22
        $this->string = $string;
23
    }
24
25
    protected function doValidation(ResponseInterface $response)
26
    {
27
        $this->assert(strpos((string)$response->getBody(), $this->string) !== false,
28
            'The given string (' . $this->string . ') was not found in this document.');
29
    }
30
}
31

src/Rules/Html/StringNotExistsRule.php 1 location

@@ 11-30 (lines=20) @@
8
/**
9
 * This rule will analyze any html document and checks if a given string is contained.
10
 */
11
class StringNotExistsRule extends StandardRule
12
{
13
    protected $contentTypes = 'text/html';
14
15
    private $string;
16
17
    /**
18
     * @param int $string The string that the document must contain
19
     */
20
    public function init($string)
21
    {
22
        $this->string = $string;
23
    }
24
25
    public function doValidation(ResponseInterface $response)
26
    {
27
        $this->assert(strpos((string)$response->getBody(), $this->string) !== false,
28
            'The given string (' . $this->string . ') was found in this document.');
29
    }
30
}
31