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

FavIconRule   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 2
c 2
b 0
f 1
lcom 1
cbo 2
dl 0
loc 26
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A doValidation() 0 10 2
1
<?php
2
3
namespace whm\Smoke\Rules\Image;
4
5
use whm\Smoke\Http\Response;
6
use whm\Smoke\Rules\StandardRule;
7
8
/**
9
 * This rule checks if the favicon that is used is the framework default.
10
 */
11
class FavIconRule extends StandardRule
12
{
13
    protected $contentTypes = array('image');
14
15
    private $favicons = array(
16
        '231567a8cc45c2cf966c4e8d99a5b7fd' => 'symfony2',
17
        '53a151ba1af3acdefe16fbbdad937ee4' => 'wordpress',
18
        'e6a9dc66179d8c9f34288b16a02f987e' => 'drupal',
19
        '8718c2998236c796896b725f264092ee' => 'typo3',
20
        '1da050bcdd95e30c3cd984cf1d450f81' => 'neos2',
21
        'abe604b0b1b232bc1d37ea23e619eb2a' => 'magento',
22
        'c1f20852dd1caf078f49de77a2de8e3f' => 'vbulletin',
23
        'cfe845e2eaaf1bf4e86b5921df1d39f3' => 'phpbb',
24
    );
25
26
    protected function doValidation(Response $response)
27
    {
28
        if (strpos((string) $response->getUri(), 'favicon.ico') === false) {
29
            return;
30
        }
31
32
        $imageHash = md5($response->getBody());
33
34
        $this->assert(!array_key_exists($imageHash, $this->favicons), 'Seems like you use the standard favicon of your framework (' . $this->favicons[$imageHash] . ').');
35
    }
36
}
37