ParsedHeaders::getXFrameOptionsResult()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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