Completed
Push — master ( 1ba115...baab82 )
by Nico
02:35
created

ServerHeader::serverContainsVersionNumber()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
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\ServerHeaderResult;
11
use nicoSWD\SecHeaderCheck\Domain\Validator\AbstractHeaderParser;
12
13
final class ServerHeader extends AbstractHeaderParser
14
{
15 2
    public function parse(): ServerHeaderResult
16
    {
17 2
        return (new ServerHeaderResult($this->getName(), $this->getValue()))
18 2
            ->setLeaksServerVersion($this->serverContainsVersionNumber());
19
    }
20
21 2
    private function serverContainsVersionNumber(): bool
22
    {
23 2
        return preg_match('~\d+\.\d+~', $this->getValue()) === 1;
24
    }
25
}
26