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

CookieHeader   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 4
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 __construct() 0 3 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\Header;
18
19
/**
20
 * Import functions
21
 */
22
use function http_build_query;
23
24
/**
25
 * Import constants
26
 */
27
use const PHP_QUERY_RFC3986;
28
29
/**
30
 * @link https://tools.ietf.org/html/rfc6265.html#section-5.4
31
 */
32
class CookieHeader extends Header
33
{
34
35
    /**
36
     * @var array
37
     */
38
    private array $value;
39
40
    /**
41
     * Constructor of the class
42
     *
43
     * @param array $value
44
     */
45 5
    public function __construct(array $value = [])
46
    {
47 5
        $this->value = $value;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 3
    public function getFieldName(): string
54
    {
55 3
        return 'Cookie';
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61 3
    public function getFieldValue(): string
62
    {
63 3
        return http_build_query($this->value, '', '; ', PHP_QUERY_RFC3986);
64
    }
65
}
66