Passed
Push — master ( cd6ebd...24ee82 )
by Anatoly
07:49 queued 03:36
created

EtagHeader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
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 37
ccs 7
cts 7
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getFieldName() 0 3 1
A getFieldValue() 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 Sunrise\Http\Message\Exception\InvalidHeaderValueException;
18
use Sunrise\Http\Message\Header;
19
20
/**
21
 * Import functions
22
 */
23
use function sprintf;
24
25
/**
26
 * @link https://tools.ietf.org/html/rfc2616#section-14.19
27
 */
28
class EtagHeader extends Header
29
{
30
31
    /**
32
     * @var string
33
     */
34
    private string $value;
35
36
    /**
37
     * Constructor of the class
38
     *
39
     * @param string $value
40
     *
41
     * @throws InvalidHeaderValueException
42
     *         If the value isn't valid.
43
     */
44 7
    public function __construct(string $value)
45
    {
46 7
        $this->validateQuotedString($value);
47
48 6
        $this->value = $value;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54 4
    public function getFieldName(): string
55
    {
56 4
        return 'ETag';
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62 4
    public function getFieldValue(): string
63
    {
64 4
        return sprintf('"%s"', $this->value);
65
    }
66
}
67