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://tools.ietf.org/html/rfc2616#section-14.12 |
27
|
|
|
*/ |
28
|
|
|
class ContentLanguageHeader extends Header |
29
|
|
|
{ |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Regular Expression for a language tag validation |
33
|
|
|
* |
34
|
|
|
* @link https://tools.ietf.org/html/rfc2616#section-3.10 |
35
|
|
|
* |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
public const RFC2616_LANGUAGE_TAG = '/^[a-zA-Z]{1,8}(?:\-[a-zA-Z]{1,8})?$/'; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var list<string> |
|
|
|
|
42
|
|
|
*/ |
43
|
|
|
private array $languages; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Constructor of the class |
47
|
|
|
* |
48
|
|
|
* @param string ...$languages |
49
|
|
|
* |
50
|
|
|
* @throws InvalidHeaderValueException |
51
|
|
|
* If one of the language codes isn't valid. |
52
|
|
|
*/ |
53
|
12 |
|
public function __construct(string ...$languages) |
54
|
|
|
{ |
55
|
|
|
/** @var list<string> $languages */ |
56
|
|
|
|
57
|
12 |
|
$this->validateValueByRegex(self::RFC2616_LANGUAGE_TAG, ...$languages); |
58
|
|
|
|
59
|
6 |
|
$this->languages = $languages; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* {@inheritdoc} |
64
|
|
|
*/ |
65
|
9 |
|
public function getFieldName(): string |
66
|
|
|
{ |
67
|
9 |
|
return 'Content-Language'; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* {@inheritdoc} |
72
|
|
|
*/ |
73
|
4 |
|
public function getFieldValue(): string |
74
|
|
|
{ |
75
|
4 |
|
return implode(', ', $this->languages); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths