ScoreCalculator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 16
c 0
b 0
f 0
ccs 0
cts 8
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A calculateScore() 0 14 3
1
<?php declare(strict_types=1);
2
3
/**
4
 * @license  http://opensource.org/licenses/mit-license.php MIT
5
 * @link     https://github.com/nicoSWD
6
 * @author   Nicolas Oelgart <[email protected]>
7
 */
8
namespace nicoSWD\SecHeaderCheck\Domain\Result;
9
10
final class ScoreCalculator
11
{
12
    public function calculateScore(ParsedHeaders $scanResult)
13
    {
14
        $possibleScore = 0;
15
        $penalties = 0;
16
17
        foreach ($scanResult->all() as $header) {
18
            $possibleScore++;
19
20
            if (!$header->isSecure()) {
21
                $penalties += 0.3;
22
            }
23
        }
24
25
        return ($possibleScore - $penalties);
26
    }
27
}
28