MultipleCheckInHeaders   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
eloc 9
c 2
b 0
f 0
dl 0
loc 21
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A check() 0 7 4
A __construct() 0 4 1
1
<?php
2
3
namespace PiedWeb\Curl;
4
5
/**
6
 * This class is an example.
7
 */
8
class MultipleCheckInHeaders
9
{
10
    protected int $expectedCode;
11
12
    protected string $expectedType;
13
14 6
    protected ?int $code = null;
15
16 6
    public function __construct(int $expectedCode = 200, string $expectedType = 'text/html')
17 6
    {
18 6
        $this->expectedCode = $expectedCode;
19
        $this->expectedType = $expectedType;
20 6
    }
21
22 6
    public function check(string $line): bool
23 3
    {
24
        if (null === $this->code && Helper::checkStatusCode($line, $this->expectedCode)) {
25
            $this->code = 200;
26 6
        }
27
28
        return 200 == $this->code && Helper::checkContentType($line, $this->expectedType);
29
    }
30
}
31