@@ -29,61 +29,61 @@ |
||
29 | 29 | class ContentEncodingHeader extends Header |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * @deprecated Use the {@see Encoding} enum. |
|
34 | - */ |
|
35 | - public const BR = Encoding::BR; |
|
32 | + /** |
|
33 | + * @deprecated Use the {@see Encoding} enum. |
|
34 | + */ |
|
35 | + public const BR = Encoding::BR; |
|
36 | 36 | |
37 | - /** |
|
38 | - * @deprecated Use the {@see Encoding} enum. |
|
39 | - */ |
|
40 | - public const COMPRESS = Encoding::COMPRESS; |
|
37 | + /** |
|
38 | + * @deprecated Use the {@see Encoding} enum. |
|
39 | + */ |
|
40 | + public const COMPRESS = Encoding::COMPRESS; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @deprecated Use the {@see Encoding} enum. |
|
44 | - */ |
|
45 | - public const DEFLATE = Encoding::DEFLATE; |
|
42 | + /** |
|
43 | + * @deprecated Use the {@see Encoding} enum. |
|
44 | + */ |
|
45 | + public const DEFLATE = Encoding::DEFLATE; |
|
46 | 46 | |
47 | - /** |
|
48 | - * @deprecated Use the {@see Encoding} enum. |
|
49 | - */ |
|
50 | - public const GZIP = Encoding::GZIP; |
|
47 | + /** |
|
48 | + * @deprecated Use the {@see Encoding} enum. |
|
49 | + */ |
|
50 | + public const GZIP = Encoding::GZIP; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @var list<string> |
|
54 | - */ |
|
55 | - private array $directives = []; |
|
52 | + /** |
|
53 | + * @var list<string> |
|
54 | + */ |
|
55 | + private array $directives = []; |
|
56 | 56 | |
57 | - /** |
|
58 | - * Constructor of the class |
|
59 | - * |
|
60 | - * @param string ...$directives |
|
61 | - * |
|
62 | - * @throws InvalidHeaderException |
|
63 | - * If one of the directives isn't valid. |
|
64 | - */ |
|
65 | - public function __construct(string ...$directives) |
|
66 | - { |
|
67 | - $this->validateToken(...$directives); |
|
57 | + /** |
|
58 | + * Constructor of the class |
|
59 | + * |
|
60 | + * @param string ...$directives |
|
61 | + * |
|
62 | + * @throws InvalidHeaderException |
|
63 | + * If one of the directives isn't valid. |
|
64 | + */ |
|
65 | + public function __construct(string ...$directives) |
|
66 | + { |
|
67 | + $this->validateToken(...$directives); |
|
68 | 68 | |
69 | - foreach ($directives as $directive) { |
|
70 | - $this->directives[] = $directive; |
|
71 | - } |
|
72 | - } |
|
69 | + foreach ($directives as $directive) { |
|
70 | + $this->directives[] = $directive; |
|
71 | + } |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * {@inheritdoc} |
|
76 | - */ |
|
77 | - public function getFieldName(): string |
|
78 | - { |
|
79 | - return 'Content-Encoding'; |
|
80 | - } |
|
74 | + /** |
|
75 | + * {@inheritdoc} |
|
76 | + */ |
|
77 | + public function getFieldName(): string |
|
78 | + { |
|
79 | + return 'Content-Encoding'; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * {@inheritdoc} |
|
84 | - */ |
|
85 | - public function getFieldValue(): string |
|
86 | - { |
|
87 | - return implode(', ', $this->directives); |
|
88 | - } |
|
82 | + /** |
|
83 | + * {@inheritdoc} |
|
84 | + */ |
|
85 | + public function getFieldValue(): string |
|
86 | + { |
|
87 | + return implode(', ', $this->directives); |
|
88 | + } |
|
89 | 89 | } |
@@ -29,53 +29,53 @@ |
||
29 | 29 | class CacheControlHeader extends Header |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * @var array<string, string> |
|
34 | - */ |
|
35 | - private array $parameters; |
|
32 | + /** |
|
33 | + * @var array<string, string> |
|
34 | + */ |
|
35 | + private array $parameters; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Constructor of the class |
|
39 | - * |
|
40 | - * @param array<array-key, mixed> $parameters |
|
41 | - * |
|
42 | - * @throws InvalidHeaderException |
|
43 | - * If the parameters aren't valid. |
|
44 | - */ |
|
45 | - public function __construct(array $parameters) |
|
46 | - { |
|
47 | - // validate and normalize the parameters... |
|
48 | - $parameters = $this->validateParameters($parameters); |
|
37 | + /** |
|
38 | + * Constructor of the class |
|
39 | + * |
|
40 | + * @param array<array-key, mixed> $parameters |
|
41 | + * |
|
42 | + * @throws InvalidHeaderException |
|
43 | + * If the parameters aren't valid. |
|
44 | + */ |
|
45 | + public function __construct(array $parameters) |
|
46 | + { |
|
47 | + // validate and normalize the parameters... |
|
48 | + $parameters = $this->validateParameters($parameters); |
|
49 | 49 | |
50 | - $this->parameters = $parameters; |
|
51 | - } |
|
50 | + $this->parameters = $parameters; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * {@inheritdoc} |
|
55 | - */ |
|
56 | - public function getFieldName(): string |
|
57 | - { |
|
58 | - return 'Cache-Control'; |
|
59 | - } |
|
53 | + /** |
|
54 | + * {@inheritdoc} |
|
55 | + */ |
|
56 | + public function getFieldName(): string |
|
57 | + { |
|
58 | + return 'Cache-Control'; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * {@inheritdoc} |
|
63 | - */ |
|
64 | - public function getFieldValue(): string |
|
65 | - { |
|
66 | - $segments = []; |
|
67 | - foreach ($this->parameters as $name => $value) { |
|
68 | - // the construction <foo=> isn't valid... |
|
69 | - if ($value === '') { |
|
70 | - $segments[] = $name; |
|
71 | - continue; |
|
72 | - } |
|
61 | + /** |
|
62 | + * {@inheritdoc} |
|
63 | + */ |
|
64 | + public function getFieldValue(): string |
|
65 | + { |
|
66 | + $segments = []; |
|
67 | + foreach ($this->parameters as $name => $value) { |
|
68 | + // the construction <foo=> isn't valid... |
|
69 | + if ($value === '') { |
|
70 | + $segments[] = $name; |
|
71 | + continue; |
|
72 | + } |
|
73 | 73 | |
74 | - $format = $this->isToken($value) ? '%s=%s' : '%s="%s"'; |
|
74 | + $format = $this->isToken($value) ? '%s=%s' : '%s="%s"'; |
|
75 | 75 | |
76 | - $segments[] = sprintf($format, $name, $value); |
|
77 | - } |
|
76 | + $segments[] = sprintf($format, $name, $value); |
|
77 | + } |
|
78 | 78 | |
79 | - return implode(', ', $segments); |
|
80 | - } |
|
79 | + return implode(', ', $segments); |
|
80 | + } |
|
81 | 81 | } |
@@ -28,41 +28,41 @@ |
||
28 | 28 | class VaryHeader extends Header |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * @var list<string> |
|
33 | - */ |
|
34 | - private array $value = []; |
|
31 | + /** |
|
32 | + * @var list<string> |
|
33 | + */ |
|
34 | + private array $value = []; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Constructor of the class |
|
38 | - * |
|
39 | - * @param string ...$value |
|
40 | - * |
|
41 | - * @throws InvalidHeaderException |
|
42 | - * If one of the values isn't valid. |
|
43 | - */ |
|
44 | - public function __construct(string ...$value) |
|
45 | - { |
|
46 | - $this->validateToken(...$value); |
|
36 | + /** |
|
37 | + * Constructor of the class |
|
38 | + * |
|
39 | + * @param string ...$value |
|
40 | + * |
|
41 | + * @throws InvalidHeaderException |
|
42 | + * If one of the values isn't valid. |
|
43 | + */ |
|
44 | + public function __construct(string ...$value) |
|
45 | + { |
|
46 | + $this->validateToken(...$value); |
|
47 | 47 | |
48 | - foreach ($value as $item) { |
|
49 | - $this->value[] = $item; |
|
50 | - } |
|
51 | - } |
|
48 | + foreach ($value as $item) { |
|
49 | + $this->value[] = $item; |
|
50 | + } |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * {@inheritdoc} |
|
55 | - */ |
|
56 | - public function getFieldName(): string |
|
57 | - { |
|
58 | - return 'Vary'; |
|
59 | - } |
|
53 | + /** |
|
54 | + * {@inheritdoc} |
|
55 | + */ |
|
56 | + public function getFieldName(): string |
|
57 | + { |
|
58 | + return 'Vary'; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * {@inheritdoc} |
|
63 | - */ |
|
64 | - public function getFieldValue(): string |
|
65 | - { |
|
66 | - return implode(', ', $this->value); |
|
67 | - } |
|
61 | + /** |
|
62 | + * {@inheritdoc} |
|
63 | + */ |
|
64 | + public function getFieldValue(): string |
|
65 | + { |
|
66 | + return implode(', ', $this->value); |
|
67 | + } |
|
68 | 68 | } |
@@ -28,39 +28,39 @@ |
||
28 | 28 | class EtagHeader extends Header |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - private string $value; |
|
31 | + /** |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + private string $value; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Constructor of the class |
|
38 | - * |
|
39 | - * @param string $value |
|
40 | - * |
|
41 | - * @throws InvalidHeaderException |
|
42 | - * If the value isn't valid. |
|
43 | - */ |
|
44 | - public function __construct(string $value) |
|
45 | - { |
|
46 | - $this->validateQuotedString($value); |
|
36 | + /** |
|
37 | + * Constructor of the class |
|
38 | + * |
|
39 | + * @param string $value |
|
40 | + * |
|
41 | + * @throws InvalidHeaderException |
|
42 | + * If the value isn't valid. |
|
43 | + */ |
|
44 | + public function __construct(string $value) |
|
45 | + { |
|
46 | + $this->validateQuotedString($value); |
|
47 | 47 | |
48 | - $this->value = $value; |
|
49 | - } |
|
48 | + $this->value = $value; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * {@inheritdoc} |
|
53 | - */ |
|
54 | - public function getFieldName(): string |
|
55 | - { |
|
56 | - return 'ETag'; |
|
57 | - } |
|
51 | + /** |
|
52 | + * {@inheritdoc} |
|
53 | + */ |
|
54 | + public function getFieldName(): string |
|
55 | + { |
|
56 | + return 'ETag'; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * {@inheritdoc} |
|
61 | - */ |
|
62 | - public function getFieldValue(): string |
|
63 | - { |
|
64 | - return sprintf('"%s"', $this->value); |
|
65 | - } |
|
59 | + /** |
|
60 | + * {@inheritdoc} |
|
61 | + */ |
|
62 | + public function getFieldValue(): string |
|
63 | + { |
|
64 | + return sprintf('"%s"', $this->value); |
|
65 | + } |
|
66 | 66 | } |
@@ -28,87 +28,87 @@ |
||
28 | 28 | class ContentRangeHeader extends Header |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * @var int |
|
33 | - */ |
|
34 | - private int $firstBytePosition; |
|
31 | + /** |
|
32 | + * @var int |
|
33 | + */ |
|
34 | + private int $firstBytePosition; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var int |
|
38 | - */ |
|
39 | - private int $lastBytePosition; |
|
36 | + /** |
|
37 | + * @var int |
|
38 | + */ |
|
39 | + private int $lastBytePosition; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var int |
|
43 | - */ |
|
44 | - private int $instanceLength; |
|
41 | + /** |
|
42 | + * @var int |
|
43 | + */ |
|
44 | + private int $instanceLength; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Constructor of the class |
|
48 | - * |
|
49 | - * @param int $firstBytePosition |
|
50 | - * @param int $lastBytePosition |
|
51 | - * @param int $instanceLength |
|
52 | - * |
|
53 | - * @throws InvalidHeaderException |
|
54 | - * If the range isn't valid. |
|
55 | - */ |
|
56 | - public function __construct(int $firstBytePosition, int $lastBytePosition, int $instanceLength) |
|
57 | - { |
|
58 | - $this->validateRange($firstBytePosition, $lastBytePosition, $instanceLength); |
|
46 | + /** |
|
47 | + * Constructor of the class |
|
48 | + * |
|
49 | + * @param int $firstBytePosition |
|
50 | + * @param int $lastBytePosition |
|
51 | + * @param int $instanceLength |
|
52 | + * |
|
53 | + * @throws InvalidHeaderException |
|
54 | + * If the range isn't valid. |
|
55 | + */ |
|
56 | + public function __construct(int $firstBytePosition, int $lastBytePosition, int $instanceLength) |
|
57 | + { |
|
58 | + $this->validateRange($firstBytePosition, $lastBytePosition, $instanceLength); |
|
59 | 59 | |
60 | - $this->firstBytePosition = $firstBytePosition; |
|
61 | - $this->lastBytePosition = $lastBytePosition; |
|
62 | - $this->instanceLength = $instanceLength; |
|
63 | - } |
|
60 | + $this->firstBytePosition = $firstBytePosition; |
|
61 | + $this->lastBytePosition = $lastBytePosition; |
|
62 | + $this->instanceLength = $instanceLength; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * {@inheritdoc} |
|
67 | - */ |
|
68 | - public function getFieldName(): string |
|
69 | - { |
|
70 | - return 'Content-Range'; |
|
71 | - } |
|
65 | + /** |
|
66 | + * {@inheritdoc} |
|
67 | + */ |
|
68 | + public function getFieldName(): string |
|
69 | + { |
|
70 | + return 'Content-Range'; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * {@inheritdoc} |
|
75 | - */ |
|
76 | - public function getFieldValue(): string |
|
77 | - { |
|
78 | - return sprintf( |
|
79 | - 'bytes %d-%d/%d', |
|
80 | - $this->firstBytePosition, |
|
81 | - $this->lastBytePosition, |
|
82 | - $this->instanceLength |
|
83 | - ); |
|
84 | - } |
|
73 | + /** |
|
74 | + * {@inheritdoc} |
|
75 | + */ |
|
76 | + public function getFieldValue(): string |
|
77 | + { |
|
78 | + return sprintf( |
|
79 | + 'bytes %d-%d/%d', |
|
80 | + $this->firstBytePosition, |
|
81 | + $this->lastBytePosition, |
|
82 | + $this->instanceLength |
|
83 | + ); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Validates the given range |
|
88 | - * |
|
89 | - * @param int $firstBytePosition |
|
90 | - * @param int $lastBytePosition |
|
91 | - * @param int $instanceLength |
|
92 | - * |
|
93 | - * @return void |
|
94 | - * |
|
95 | - * @throws InvalidHeaderException |
|
96 | - * If the range isn't valid. |
|
97 | - */ |
|
98 | - private function validateRange(int $firstBytePosition, int $lastBytePosition, int $instanceLength): void |
|
99 | - { |
|
100 | - if (! ($firstBytePosition <= $lastBytePosition)) { |
|
101 | - throw new InvalidHeaderException( |
|
102 | - 'The "first-byte-pos" value of the content range ' . |
|
103 | - 'must be less than or equal to the "last-byte-pos" value' |
|
104 | - ); |
|
105 | - } |
|
86 | + /** |
|
87 | + * Validates the given range |
|
88 | + * |
|
89 | + * @param int $firstBytePosition |
|
90 | + * @param int $lastBytePosition |
|
91 | + * @param int $instanceLength |
|
92 | + * |
|
93 | + * @return void |
|
94 | + * |
|
95 | + * @throws InvalidHeaderException |
|
96 | + * If the range isn't valid. |
|
97 | + */ |
|
98 | + private function validateRange(int $firstBytePosition, int $lastBytePosition, int $instanceLength): void |
|
99 | + { |
|
100 | + if (! ($firstBytePosition <= $lastBytePosition)) { |
|
101 | + throw new InvalidHeaderException( |
|
102 | + 'The "first-byte-pos" value of the content range ' . |
|
103 | + 'must be less than or equal to the "last-byte-pos" value' |
|
104 | + ); |
|
105 | + } |
|
106 | 106 | |
107 | - if (! ($lastBytePosition < $instanceLength)) { |
|
108 | - throw new InvalidHeaderException( |
|
109 | - 'The "last-byte-pos" value of the content range ' . |
|
110 | - 'must be less than the "instance-length" value' |
|
111 | - ); |
|
112 | - } |
|
113 | - } |
|
107 | + if (! ($lastBytePosition < $instanceLength)) { |
|
108 | + throw new InvalidHeaderException( |
|
109 | + 'The "last-byte-pos" value of the content range ' . |
|
110 | + 'must be less than the "instance-length" value' |
|
111 | + ); |
|
112 | + } |
|
113 | + } |
|
114 | 114 | } |
@@ -97,14 +97,14 @@ |
||
97 | 97 | */ |
98 | 98 | private function validateRange(int $firstBytePosition, int $lastBytePosition, int $instanceLength): void |
99 | 99 | { |
100 | - if (! ($firstBytePosition <= $lastBytePosition)) { |
|
100 | + if (!($firstBytePosition <= $lastBytePosition)) { |
|
101 | 101 | throw new InvalidHeaderException( |
102 | 102 | 'The "first-byte-pos" value of the content range ' . |
103 | 103 | 'must be less than or equal to the "last-byte-pos" value' |
104 | 104 | ); |
105 | 105 | } |
106 | 106 | |
107 | - if (! ($lastBytePosition < $instanceLength)) { |
|
107 | + if (!($lastBytePosition < $instanceLength)) { |
|
108 | 108 | throw new InvalidHeaderException( |
109 | 109 | 'The "last-byte-pos" value of the content range ' . |
110 | 110 | 'must be less than the "instance-length" value' |
@@ -28,60 +28,60 @@ |
||
28 | 28 | class AgeHeader extends Header |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * @var int |
|
33 | - */ |
|
34 | - private int $value; |
|
31 | + /** |
|
32 | + * @var int |
|
33 | + */ |
|
34 | + private int $value; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Constructor of the class |
|
38 | - * |
|
39 | - * @param int $value |
|
40 | - * |
|
41 | - * @throws InvalidHeaderException |
|
42 | - * If the value isn't valid. |
|
43 | - */ |
|
44 | - public function __construct(int $value) |
|
45 | - { |
|
46 | - $this->validateValue($value); |
|
36 | + /** |
|
37 | + * Constructor of the class |
|
38 | + * |
|
39 | + * @param int $value |
|
40 | + * |
|
41 | + * @throws InvalidHeaderException |
|
42 | + * If the value isn't valid. |
|
43 | + */ |
|
44 | + public function __construct(int $value) |
|
45 | + { |
|
46 | + $this->validateValue($value); |
|
47 | 47 | |
48 | - $this->value = $value; |
|
49 | - } |
|
48 | + $this->value = $value; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * {@inheritdoc} |
|
53 | - */ |
|
54 | - public function getFieldName(): string |
|
55 | - { |
|
56 | - return 'Age'; |
|
57 | - } |
|
51 | + /** |
|
52 | + * {@inheritdoc} |
|
53 | + */ |
|
54 | + public function getFieldName(): string |
|
55 | + { |
|
56 | + return 'Age'; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * {@inheritdoc} |
|
61 | - */ |
|
62 | - public function getFieldValue(): string |
|
63 | - { |
|
64 | - return sprintf('%d', $this->value); |
|
65 | - } |
|
59 | + /** |
|
60 | + * {@inheritdoc} |
|
61 | + */ |
|
62 | + public function getFieldValue(): string |
|
63 | + { |
|
64 | + return sprintf('%d', $this->value); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Validates the given value |
|
69 | - * |
|
70 | - * @param int $value |
|
71 | - * |
|
72 | - * @return void |
|
73 | - * |
|
74 | - * @throws InvalidHeaderException |
|
75 | - * If the value isn't valid. |
|
76 | - */ |
|
77 | - private function validateValue(int $value): void |
|
78 | - { |
|
79 | - if (! ($value >= 0)) { |
|
80 | - throw new InvalidHeaderException(sprintf( |
|
81 | - 'The value "%2$d" for the header "%1$s" is not valid', |
|
82 | - $this->getFieldName(), |
|
83 | - $value |
|
84 | - )); |
|
85 | - } |
|
86 | - } |
|
67 | + /** |
|
68 | + * Validates the given value |
|
69 | + * |
|
70 | + * @param int $value |
|
71 | + * |
|
72 | + * @return void |
|
73 | + * |
|
74 | + * @throws InvalidHeaderException |
|
75 | + * If the value isn't valid. |
|
76 | + */ |
|
77 | + private function validateValue(int $value): void |
|
78 | + { |
|
79 | + if (! ($value >= 0)) { |
|
80 | + throw new InvalidHeaderException(sprintf( |
|
81 | + 'The value "%2$d" for the header "%1$s" is not valid', |
|
82 | + $this->getFieldName(), |
|
83 | + $value |
|
84 | + )); |
|
85 | + } |
|
86 | + } |
|
87 | 87 | } |
@@ -76,7 +76,7 @@ |
||
76 | 76 | */ |
77 | 77 | private function validateValue(int $value): void |
78 | 78 | { |
79 | - if (! ($value >= 0)) { |
|
79 | + if (!($value >= 0)) { |
|
80 | 80 | throw new InvalidHeaderException(sprintf( |
81 | 81 | 'The value "%2$d" for the header "%1$s" is not valid', |
82 | 82 | $this->getFieldName(), |
@@ -28,41 +28,41 @@ |
||
28 | 28 | class AccessControlExposeHeadersHeader extends Header |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * @var list<string> |
|
33 | - */ |
|
34 | - private array $headers = []; |
|
31 | + /** |
|
32 | + * @var list<string> |
|
33 | + */ |
|
34 | + private array $headers = []; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Constructor of the class |
|
38 | - * |
|
39 | - * @param string ...$headers |
|
40 | - * |
|
41 | - * @throws InvalidHeaderException |
|
42 | - * If one of the header names isn't valid. |
|
43 | - */ |
|
44 | - public function __construct(string ...$headers) |
|
45 | - { |
|
46 | - $this->validateToken(...$headers); |
|
36 | + /** |
|
37 | + * Constructor of the class |
|
38 | + * |
|
39 | + * @param string ...$headers |
|
40 | + * |
|
41 | + * @throws InvalidHeaderException |
|
42 | + * If one of the header names isn't valid. |
|
43 | + */ |
|
44 | + public function __construct(string ...$headers) |
|
45 | + { |
|
46 | + $this->validateToken(...$headers); |
|
47 | 47 | |
48 | - foreach ($headers as $header) { |
|
49 | - $this->headers[] = $header; |
|
50 | - } |
|
51 | - } |
|
48 | + foreach ($headers as $header) { |
|
49 | + $this->headers[] = $header; |
|
50 | + } |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * {@inheritdoc} |
|
55 | - */ |
|
56 | - public function getFieldName(): string |
|
57 | - { |
|
58 | - return 'Access-Control-Expose-Headers'; |
|
59 | - } |
|
53 | + /** |
|
54 | + * {@inheritdoc} |
|
55 | + */ |
|
56 | + public function getFieldName(): string |
|
57 | + { |
|
58 | + return 'Access-Control-Expose-Headers'; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * {@inheritdoc} |
|
63 | - */ |
|
64 | - public function getFieldValue(): string |
|
65 | - { |
|
66 | - return implode(', ', $this->headers); |
|
67 | - } |
|
61 | + /** |
|
62 | + * {@inheritdoc} |
|
63 | + */ |
|
64 | + public function getFieldValue(): string |
|
65 | + { |
|
66 | + return implode(', ', $this->headers); |
|
67 | + } |
|
68 | 68 | } |
@@ -31,55 +31,55 @@ |
||
31 | 31 | class LinkHeader extends Header |
32 | 32 | { |
33 | 33 | |
34 | - /** |
|
35 | - * @var UriInterface |
|
36 | - */ |
|
37 | - private UriInterface $uri; |
|
34 | + /** |
|
35 | + * @var UriInterface |
|
36 | + */ |
|
37 | + private UriInterface $uri; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var array<string, string> |
|
41 | - */ |
|
42 | - private array $parameters; |
|
39 | + /** |
|
40 | + * @var array<string, string> |
|
41 | + */ |
|
42 | + private array $parameters; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Constructor of the class |
|
46 | - * |
|
47 | - * @param mixed $uri |
|
48 | - * @param array<array-key, mixed> $parameters |
|
49 | - * |
|
50 | - * @throws InvalidUriException |
|
51 | - * If the URI isn't valid. |
|
52 | - * |
|
53 | - * @throws InvalidHeaderException |
|
54 | - * If the parameters aren't valid. |
|
55 | - */ |
|
56 | - public function __construct($uri, array $parameters = []) |
|
57 | - { |
|
58 | - // validate and normalize the parameters... |
|
59 | - $parameters = $this->validateParameters($parameters); |
|
44 | + /** |
|
45 | + * Constructor of the class |
|
46 | + * |
|
47 | + * @param mixed $uri |
|
48 | + * @param array<array-key, mixed> $parameters |
|
49 | + * |
|
50 | + * @throws InvalidUriException |
|
51 | + * If the URI isn't valid. |
|
52 | + * |
|
53 | + * @throws InvalidHeaderException |
|
54 | + * If the parameters aren't valid. |
|
55 | + */ |
|
56 | + public function __construct($uri, array $parameters = []) |
|
57 | + { |
|
58 | + // validate and normalize the parameters... |
|
59 | + $parameters = $this->validateParameters($parameters); |
|
60 | 60 | |
61 | - $this->uri = Uri::create($uri); |
|
62 | - $this->parameters = $parameters; |
|
63 | - } |
|
61 | + $this->uri = Uri::create($uri); |
|
62 | + $this->parameters = $parameters; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * {@inheritdoc} |
|
67 | - */ |
|
68 | - public function getFieldName(): string |
|
69 | - { |
|
70 | - return 'Link'; |
|
71 | - } |
|
65 | + /** |
|
66 | + * {@inheritdoc} |
|
67 | + */ |
|
68 | + public function getFieldName(): string |
|
69 | + { |
|
70 | + return 'Link'; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * {@inheritdoc} |
|
75 | - */ |
|
76 | - public function getFieldValue(): string |
|
77 | - { |
|
78 | - $v = sprintf('<%s>', $this->uri->__toString()); |
|
79 | - foreach ($this->parameters as $name => $value) { |
|
80 | - $v .= sprintf('; %s="%s"', $name, $value); |
|
81 | - } |
|
73 | + /** |
|
74 | + * {@inheritdoc} |
|
75 | + */ |
|
76 | + public function getFieldValue(): string |
|
77 | + { |
|
78 | + $v = sprintf('<%s>', $this->uri->__toString()); |
|
79 | + foreach ($this->parameters as $name => $value) { |
|
80 | + $v .= sprintf('; %s="%s"', $name, $value); |
|
81 | + } |
|
82 | 82 | |
83 | - return $v; |
|
84 | - } |
|
83 | + return $v; |
|
84 | + } |
|
85 | 85 | } |
@@ -29,74 +29,74 @@ |
||
29 | 29 | class ContentSecurityPolicyHeader extends Header |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * Regular Expression for a directive name validation |
|
34 | - * |
|
35 | - * @link https://www.w3.org/TR/CSP3/#framework-directives |
|
36 | - * |
|
37 | - * @var string |
|
38 | - */ |
|
39 | - public const VALID_DIRECTIVE_NAME = '/^[0-9A-Za-z\-]+$/'; |
|
32 | + /** |
|
33 | + * Regular Expression for a directive name validation |
|
34 | + * |
|
35 | + * @link https://www.w3.org/TR/CSP3/#framework-directives |
|
36 | + * |
|
37 | + * @var string |
|
38 | + */ |
|
39 | + public const VALID_DIRECTIVE_NAME = '/^[0-9A-Za-z\-]+$/'; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Regular Expression for a directive value validation |
|
43 | - * |
|
44 | - * @link https://www.w3.org/TR/CSP3/#framework-directives |
|
45 | - * |
|
46 | - * @var string |
|
47 | - */ |
|
48 | - public const VALID_DIRECTIVE_VALUE = '/^[\x09\x20-\x2B\x2D-\x3A\x3C-\x7E]*$/'; |
|
41 | + /** |
|
42 | + * Regular Expression for a directive value validation |
|
43 | + * |
|
44 | + * @link https://www.w3.org/TR/CSP3/#framework-directives |
|
45 | + * |
|
46 | + * @var string |
|
47 | + */ |
|
48 | + public const VALID_DIRECTIVE_VALUE = '/^[\x09\x20-\x2B\x2D-\x3A\x3C-\x7E]*$/'; |
|
49 | 49 | |
50 | - /** |
|
51 | - * @var array<string, string> |
|
52 | - */ |
|
53 | - private array $parameters; |
|
50 | + /** |
|
51 | + * @var array<string, string> |
|
52 | + */ |
|
53 | + private array $parameters; |
|
54 | 54 | |
55 | - /** |
|
56 | - * Constructor of the class |
|
57 | - * |
|
58 | - * @param array<array-key, mixed> $parameters |
|
59 | - * |
|
60 | - * @throws InvalidHeaderException |
|
61 | - * If the parameters aren't valid. |
|
62 | - */ |
|
63 | - public function __construct(array $parameters = []) |
|
64 | - { |
|
65 | - // validate and normalize the parameters... |
|
66 | - $parameters = $this->validateParametersByRegex( |
|
67 | - $parameters, |
|
68 | - self::VALID_DIRECTIVE_NAME, |
|
69 | - self::VALID_DIRECTIVE_VALUE |
|
70 | - ); |
|
55 | + /** |
|
56 | + * Constructor of the class |
|
57 | + * |
|
58 | + * @param array<array-key, mixed> $parameters |
|
59 | + * |
|
60 | + * @throws InvalidHeaderException |
|
61 | + * If the parameters aren't valid. |
|
62 | + */ |
|
63 | + public function __construct(array $parameters = []) |
|
64 | + { |
|
65 | + // validate and normalize the parameters... |
|
66 | + $parameters = $this->validateParametersByRegex( |
|
67 | + $parameters, |
|
68 | + self::VALID_DIRECTIVE_NAME, |
|
69 | + self::VALID_DIRECTIVE_VALUE |
|
70 | + ); |
|
71 | 71 | |
72 | - $this->parameters = $parameters; |
|
73 | - } |
|
72 | + $this->parameters = $parameters; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * {@inheritdoc} |
|
77 | - */ |
|
78 | - public function getFieldName(): string |
|
79 | - { |
|
80 | - return 'Content-Security-Policy'; |
|
81 | - } |
|
75 | + /** |
|
76 | + * {@inheritdoc} |
|
77 | + */ |
|
78 | + public function getFieldName(): string |
|
79 | + { |
|
80 | + return 'Content-Security-Policy'; |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * {@inheritdoc} |
|
85 | - */ |
|
86 | - public function getFieldValue(): string |
|
87 | - { |
|
88 | - $directives = []; |
|
89 | - foreach ($this->parameters as $directive => $value) { |
|
90 | - // the directive can be without value, |
|
91 | - // e.g. sandbox, upgrade-insecure-requests, etc. |
|
92 | - if ($value === '') { |
|
93 | - $directives[] = $directive; |
|
94 | - continue; |
|
95 | - } |
|
83 | + /** |
|
84 | + * {@inheritdoc} |
|
85 | + */ |
|
86 | + public function getFieldValue(): string |
|
87 | + { |
|
88 | + $directives = []; |
|
89 | + foreach ($this->parameters as $directive => $value) { |
|
90 | + // the directive can be without value, |
|
91 | + // e.g. sandbox, upgrade-insecure-requests, etc. |
|
92 | + if ($value === '') { |
|
93 | + $directives[] = $directive; |
|
94 | + continue; |
|
95 | + } |
|
96 | 96 | |
97 | - $directives[] = sprintf('%s %s', $directive, $value); |
|
98 | - } |
|
97 | + $directives[] = sprintf('%s %s', $directive, $value); |
|
98 | + } |
|
99 | 99 | |
100 | - return implode('; ', $directives); |
|
101 | - } |
|
100 | + return implode('; ', $directives); |
|
101 | + } |
|
102 | 102 | } |