Passed
Pull Request — master (#27)
by Anatoly
04:06
created

RetryAfterHeader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFieldValue() 0 3 1
A __construct() 0 3 1
A getFieldName() 0 3 1
1
<?php declare(strict_types=1);
2
3
/**
4
 * It's free open-source software released under the MIT License.
5
 *
6
 * @author Anatoly Nekhay <[email protected]>
7
 * @copyright Copyright (c) 2018, Anatoly Nekhay
8
 * @license https://github.com/sunrise-php/http-message/blob/master/LICENSE
9
 * @link https://github.com/sunrise-php/http-message
10
 */
11
12
namespace Sunrise\Http\Message\Header;
13
14
/**
15
 * Import classes
16
 */
17
use DateTimeInterface;
18
use Sunrise\Http\Message\Header;
19
20
/**
21
 * @link https://tools.ietf.org/html/rfc2616#section-14.37
22
 * @link https://tools.ietf.org/html/rfc822#section-5
23
 */
24
class RetryAfterHeader extends Header
25
{
26
27
    /**
28
     * @var DateTimeInterface
29
     */
30
    private DateTimeInterface $timestamp;
31
32
    /**
33
     * Constructor of the class
34
     *
35
     * @param DateTimeInterface $timestamp
36
     */
37 7
    public function __construct(DateTimeInterface $timestamp)
38
    {
39 7
        $this->timestamp = $timestamp;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 3
    public function getFieldName(): string
46
    {
47 3
        return 'Retry-After';
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 5
    public function getFieldValue(): string
54
    {
55 5
        return $this->formatDateTime($this->timestamp);
56
    }
57
}
58