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

AccessControlAllowHeadersHeader   A

Complexity

Total Complexity 3

Size/Duplication

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFieldValue() 0 3 1
A getFieldName() 0 3 1
A __construct() 0 7 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 implode;
24
25
/**
26
 * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers
27
 */
28
class AccessControlAllowHeadersHeader extends Header
29
{
30
31
    /**
32
     * @var list<string>
0 ignored issues
show
Bug introduced by
The type Sunrise\Http\Message\Header\list was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
33
     */
34
    private array $headers;
35
36
    /**
37
     * Constructor of the class
38
     *
39
     * @param string ...$headers
40
     *
41
     * @throws InvalidHeaderValueException
42
     *         If one of the header names isn't valid.
43
     */
44 10
    public function __construct(string ...$headers)
45
    {
46
        /** @var list<string> $headers */
47
48 10
        $this->validateToken(...$headers);
49
50 6
        $this->headers = $headers;
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56 7
    public function getFieldName(): string
57
    {
58 7
        return 'Access-Control-Allow-Headers';
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64 4
    public function getFieldValue(): string
65
    {
66 4
        return implode(', ', $this->headers);
67
    }
68
}
69