TechHeader   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getHeaders() 0 12 3
1
<?php
2
/**
3
 * Mage Scan
4
 *
5
 * PHP version 5
6
 *
7
 * @category  MageScan
8
 * @package   MageScan
9
 * @author    Steve Robbins <[email protected]>
10
 * @copyright 2015 Steve Robbins
11
 * @license   http://creativecommons.org/licenses/by/4.0/ CC BY 4.0
12
 * @link      https://github.com/steverobbins/magescan
13
 */
14
15
namespace MageScan\Check;
16
17
/**
18
 * Check for technical information exposed in the headers of a response
19
 *
20
 * @category  MageScan
21
 * @package   MageScan
22
 * @author    Steve Robbins <[email protected]>
23
 * @copyright 2015 Steve Robbins
24
 * @license   http://creativecommons.org/licenses/by/4.0/ CC BY 4.0
25
 * @link      https://github.com/steverobbins/magescan
26
 */
27
class TechHeader extends AbstractCheck
28
{
29
    /**
30
     * Headers that provide information about the technology used
31
     *
32
     * @var array
33
     */
34
    protected $techHeader = [
35
        'Server',
36
        'Via',
37
        'X-Mod-Pagespeed',
38
        'X-Page-Speed',
39
        'X-Powered-By',
40
    ];
41
42
    /**
43
     * Crawl the url's headers
44
     *
45
     * @return array
46
     */
47
    public function getHeaders()
48
    {
49
        $response = $this->getRequest()->head();
50
        $rows = [];
51
        $headers = $response->getHeaders();
52
        foreach ($this->techHeader as $value) {
53
            if (isset($headers[$value])) {
54
                $rows[$value] = $headers[$value][0];
55
            }
56
        }
57
        return $rows;
58
    }
59
}
60