Passed
Pull Request — master (#22)
by Aleksei
02:39
created

DateHeader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A addValue() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Http\Header;
6
7
use DateTimeInterface;
8
use Yiisoft\Http\Header\Internal\BaseHeaderValue;
9
use Yiisoft\Http\Header\Value\Date;
10
11
/**
12
 * @method $this withValue(BaseHeaderValue|DateTimeInterface|string $value)
13
 * @method $this withValues(BaseHeaderValue[]|DateTimeInterface[]|string[] $value)
14
 */
15
final class DateHeader extends Header
16
{
17
    protected const DEFAULT_VALUE_CLASS = Date::class;
18
19
    protected function addValue($value): void
20
    {
21
        if ($value instanceof DateTimeInterface) {
22
            $value = $value->format(DateTimeInterface::RFC7231);
23
        }
24
        parent::addValue($value);
25
    }
26
}
27