ParsedHeaders   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 5
eloc 7
dl 0
loc 29
c 0
b 0
f 0
ccs 6
cts 12
cp 0.5
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 3 1
A add() 0 3 1
A getXFrameOptionsResult() 0 3 1
A getContentSecurityPolicyResult() 0 3 1
A __construct() 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;
9
10
use nicoSWD\SecHeaderCheck\Domain\Header\SecurityHeader;
11
use nicoSWD\SecHeaderCheck\Domain\Result\Result\ContentSecurityPolicyHeaderResult;
12
use nicoSWD\SecHeaderCheck\Domain\Result\Result\XFrameOptionsHeaderResult;
13
14
final class ParsedHeaders
15
{
16
    /** @var ParsedHeaderBag */
17
    private $headers;
18
19 2
    public function __construct()
20
    {
21 2
        $this->headers = new ParsedHeaderBag();
22 2
    }
23
24 2
    public function add(AbstractParsedHeader $header): void
25
    {
26 2
        $this->headers->add($header);
27 2
    }
28
29
    public function all(): ParsedHeaderBag
30
    {
31
        return $this->headers;
32
    }
33
34
    /** @return ContentSecurityPolicyHeaderResult[] */
35
    public function getContentSecurityPolicyResult()
36
    {
37
        return $this->headers->findMultiple(SecurityHeader::CONTENT_SECURITY_POLICY);
38
    }
39
40
    public function getXFrameOptionsResult(): ?XFrameOptionsHeaderResult
41
    {
42
        return $this->headers->findOne(SecurityHeader::X_FRAME_OPTIONS);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->headers->f...eader::X_FRAME_OPTIONS) could return the type nicoSWD\SecHeaderCheck\D...lt\AbstractParsedHeader which includes types incompatible with the type-hinted return nicoSWD\SecHeaderCheck\D...ptionsHeaderResult|null. Consider adding an additional type-check to rule them out.
Loading history...
43
    }
44
}
45