ScoreCalculator::calculateScore()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 14
c 0
b 0
f 0
ccs 0
cts 8
cp 0
rs 10
cc 3
nc 3
nop 1
crap 12
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