XContentTypeOptionsHeader::isNoSniff()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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\Validator\Header;
9
10
use nicoSWD\SecHeaderCheck\Domain\Result\Result\XContentTypeOptionsHeaderResult;
11
use nicoSWD\SecHeaderCheck\Domain\Validator\AbstractHeaderParser;
12
13
final class XContentTypeOptionsHeader extends AbstractHeaderParser
14
{
15
    private const NO_SNIFF = 'nosniff';
16
17 4
    public function parse(): XContentTypeOptionsHeaderResult
18
    {
19 4
        return (new XContentTypeOptionsHeaderResult($this->getName(), $this->getValue()))
20 4
            ->setIsNoSniff($this->isNoSniff());
21
    }
22
23 4
    private function isNoSniff(): bool
24
    {
25 4
        return strtolower($this->getValue()) === self::NO_SNIFF;
26
    }
27
}
28