ServerProcessor   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A header() 0 3 1
A process() 0 11 2
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\Processor;
9
10
use nicoSWD\SecHeaderCheck\Domain\Result\ObservationCollection;
11
use nicoSWD\SecHeaderCheck\Domain\Result\ParsedHeaders;
12
use nicoSWD\SecHeaderCheck\Domain\Result\Result\ServerHeaderResult;
13
use nicoSWD\SecHeaderCheck\Domain\Result\Warning\ServerDisclosedVersionNumberWarning;
14
use nicoSWD\SecHeaderCheck\Domain\Result\Warning\ServerDoesNotLeakVersionKudos;
15
16
final class ServerProcessor extends AbstractProcessor
17
{
18
    public function process(ParsedHeaders $parsedHeaders): void
19
    {
20
        $observations = new ObservationCollection();
21
22
        if ($this->header()->leaksServerVersion()) {
23
            $observations->addWarning(new ServerDisclosedVersionNumberWarning());
24
        } else {
25
            $observations->addKudos(new ServerDoesNotLeakVersionKudos());
26
        }
27
28
        $this->addObservations($observations);
29
    }
30
31
    private function header(): ServerHeaderResult
32
    {
33
        return $this->parsedHeader;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->parsedHeader returns the type nicoSWD\SecHeaderCheck\D...lt\AbstractParsedHeader which includes types incompatible with the type-hinted return nicoSWD\SecHeaderCheck\D...sult\ServerHeaderResult.
Loading history...
34
    }
35
}
36