NoIndexRule   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A doValidation() 0 13 3
1
<?php
2
3
namespace whm\Smoke\Rules\Html;
4
5
use Psr\Http\Message\ResponseInterface;
6
use Symfony\Component\DomCrawler\Crawler;
7
use whm\Smoke\Http\Response;
8
use whm\Smoke\Rules\StandardRule;
9
10
/**
11
 * This rule checks if the no-index robots meta tag is not set.
12
 */
13
class NoIndexRule extends StandardRule
14
{
15
    protected $contentTypes = array('text/html');
16
17
    protected function doValidation(ResponseInterface $response)
18
    {
19
        if ($response->getStatusCode() >= 300) {
20
            return;
21
        }
22
23
        $crawler = new Crawler((string)$response->getBody());
24
        $metaTags = $crawler->filterXPath("//meta[@name='robots']/@content");
25
26
        foreach ($metaTags as $metaTag) {
27
            $this->assert(strpos($metaTag->nodeValue, 'no-index') === false, 'A meta tag "robots" with the value "no-index" was found');
28
        }
29
    }
30
}
31