RegExNotExistsRule   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 22
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 4 1
A doValidation() 0 7 2
1
<?php
2
3
namespace whm\Smoke\Rules\Html;
4
5
use Psr\Http\Message\ResponseInterface;
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
class RegExNotExistsRule extends StandardRule
12
{
13
    private $regExs;
14
15
    protected $contentTypes = array('text/html');
16
17
    /**
18
     * @param int $string The string that the document must contain
0 ignored issues
show
Bug introduced by
There is no parameter named $string. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
19
     */
20
    public function init(array $regExs)
21
    {
22
        $this->regExs = $regExs;
23
    }
24
25
    protected function doValidation(ResponseInterface $response)
26
    {
27
        foreach ($this->regExs as $regEx) {
28
            $this->assert(preg_match('^' . $regEx . '^', (string)$response->getBody()) === 0,
29
                'The given regular expression (' . $regEx . ') was found in this document.');
30
        }
31
    }
32
}
33