Completed
Branch master (1f9106)
by Nils
02:44
created

StringNotExistsRule::doValidation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 5
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace whm\Smoke\Rules\Html;
4
5
use whm\Smoke\Http\Response;
6
use whm\Smoke\Rules\StandardRule;
7
8
/**
9
 * This rule will analyze any html document and checks if a given string is contained.
10
 */
11 View Code Duplication
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(Response $response)
26
    {
27
        $this->assert(strpos($response->getBody(), $this->string) !== false,
28
            'The given string (' . $this->string . ') was found in this document.');
29
    }
30
}
31