XFrameOptionsProcessor   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
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 process() 0 11 3
A header() 0 3 1
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\Warning\XFrameOptionsWithInsecureValueError;
13
use nicoSWD\SecHeaderCheck\Domain\Result\Result\XFrameOptionsHeaderResult;
14
use nicoSWD\SecHeaderCheck\Domain\Result\Warning\XFrameOptionsWithSecureOriginKudos;
15
16
final class XFrameOptionsProcessor extends AbstractProcessor
17
{
18
    public function process(ParsedHeaders $parsedHeaders): void
19
    {
20
        $observations = new ObservationCollection();
21
22
        if (!$this->header()->getHasSecureOrigin() && !$this->header()->hasAllowFrom()) {
23
            $observations->addError(new XFrameOptionsWithInsecureValueError());
24
        } else {
25
            $observations->addKudos(new XFrameOptionsWithSecureOriginKudos());
26
        }
27
28
        $this->addObservations($observations);
29
    }
30
31
    private function header(): XFrameOptionsHeaderResult
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...rameOptionsHeaderResult.
Loading history...
34
    }
35
}
36