@@ -28,60 +28,60 @@ |
||
28 | 28 | class AccessControlMaxAgeHeader 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 'Access-Control-Max-Age'; |
|
57 | - } |
|
51 | + /** |
|
52 | + * {@inheritdoc} |
|
53 | + */ |
|
54 | + public function getFieldName(): string |
|
55 | + { |
|
56 | + return 'Access-Control-Max-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 === -1 || $value >= 1)) { |
|
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 === -1 || $value >= 1)) { |
|
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 === -1 || $value >= 1)) { |
|
79 | + if (!($value === -1 || $value >= 1)) { |
|
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,55 +28,55 @@ |
||
28 | 28 | class ContentDispositionHeader extends Header |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - private string $type; |
|
31 | + /** |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + private string $type; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var array<string, string> |
|
38 | - */ |
|
39 | - private array $parameters; |
|
36 | + /** |
|
37 | + * @var array<string, string> |
|
38 | + */ |
|
39 | + private array $parameters; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Constructor of the class |
|
43 | - * |
|
44 | - * @param string $type |
|
45 | - * @param array<array-key, mixed> $parameters |
|
46 | - * |
|
47 | - * @throws InvalidHeaderException |
|
48 | - * - If the type isn't valid; |
|
49 | - * - If the parameters aren't valid. |
|
50 | - */ |
|
51 | - public function __construct(string $type, array $parameters = []) |
|
52 | - { |
|
53 | - $this->validateToken($type); |
|
41 | + /** |
|
42 | + * Constructor of the class |
|
43 | + * |
|
44 | + * @param string $type |
|
45 | + * @param array<array-key, mixed> $parameters |
|
46 | + * |
|
47 | + * @throws InvalidHeaderException |
|
48 | + * - If the type isn't valid; |
|
49 | + * - If the parameters aren't valid. |
|
50 | + */ |
|
51 | + public function __construct(string $type, array $parameters = []) |
|
52 | + { |
|
53 | + $this->validateToken($type); |
|
54 | 54 | |
55 | - // validate and normalize the parameters,,, |
|
56 | - $parameters = $this->validateParameters($parameters); |
|
55 | + // validate and normalize the parameters,,, |
|
56 | + $parameters = $this->validateParameters($parameters); |
|
57 | 57 | |
58 | - $this->type = $type; |
|
59 | - $this->parameters = $parameters; |
|
60 | - } |
|
58 | + $this->type = $type; |
|
59 | + $this->parameters = $parameters; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * {@inheritdoc} |
|
64 | - */ |
|
65 | - public function getFieldName(): string |
|
66 | - { |
|
67 | - return 'Content-Disposition'; |
|
68 | - } |
|
62 | + /** |
|
63 | + * {@inheritdoc} |
|
64 | + */ |
|
65 | + public function getFieldName(): string |
|
66 | + { |
|
67 | + return 'Content-Disposition'; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * {@inheritdoc} |
|
72 | - */ |
|
73 | - public function getFieldValue(): string |
|
74 | - { |
|
75 | - $v = $this->type; |
|
76 | - foreach ($this->parameters as $name => $value) { |
|
77 | - $v .= sprintf('; %s="%s"', $name, $value); |
|
78 | - } |
|
70 | + /** |
|
71 | + * {@inheritdoc} |
|
72 | + */ |
|
73 | + public function getFieldValue(): string |
|
74 | + { |
|
75 | + $v = $this->type; |
|
76 | + foreach ($this->parameters as $name => $value) { |
|
77 | + $v .= sprintf('; %s="%s"', $name, $value); |
|
78 | + } |
|
79 | 79 | |
80 | - return $v; |
|
81 | - } |
|
80 | + return $v; |
|
81 | + } |
|
82 | 82 | } |
@@ -30,124 +30,124 @@ |
||
30 | 30 | class WarningHeader extends Header |
31 | 31 | { |
32 | 32 | |
33 | - /** |
|
34 | - * @deprecated Use the {@see WarningCode} enum. |
|
35 | - */ |
|
36 | - public const HTTP_WARNING_CODE_RESPONSE_IS_STALE = WarningCode::RESPONSE_IS_STALE; |
|
37 | - |
|
38 | - /** |
|
39 | - * @deprecated Use the {@see WarningCode} enum. |
|
40 | - */ |
|
41 | - public const HTTP_WARNING_CODE_REVALIDATION_FAILED = WarningCode::REVALIDATION_FAILED; |
|
42 | - |
|
43 | - /** |
|
44 | - * @deprecated Use the {@see WarningCode} enum. |
|
45 | - */ |
|
46 | - public const HTTP_WARNING_CODE_DISCONNECTED_OPERATION = WarningCode::DISCONNECTED_OPERATION; |
|
47 | - |
|
48 | - /** |
|
49 | - * @deprecated Use the {@see WarningCode} enum. |
|
50 | - */ |
|
51 | - public const HTTP_WARNING_CODE_HEURISTIC_EXPIRATION = WarningCode::HEURISTIC_EXPIRATION; |
|
52 | - |
|
53 | - /** |
|
54 | - * @deprecated Use the {@see WarningCode} enum. |
|
55 | - */ |
|
56 | - public const HTTP_WARNING_CODE_MISCELLANEOUS_WARNING = WarningCode::MISCELLANEOUS_WARNING; |
|
57 | - |
|
58 | - /** |
|
59 | - * @deprecated Use the {@see WarningCode} enum. |
|
60 | - */ |
|
61 | - public const HTTP_WARNING_CODE_TRANSFORMATION_APPLIED = WarningCode::TRANSFORMATION_APPLIED; |
|
62 | - |
|
63 | - /** |
|
64 | - * @deprecated Use the {@see WarningCode} enum. |
|
65 | - */ |
|
66 | - public const HTTP_WARNING_CODE_MISCELLANEOUS_PERSISTENT_WARNING = WarningCode::MISCELLANEOUS_PERSISTENT_WARNING; |
|
67 | - |
|
68 | - /** |
|
69 | - * @var int |
|
70 | - */ |
|
71 | - private int $code; |
|
72 | - |
|
73 | - /** |
|
74 | - * @var string |
|
75 | - */ |
|
76 | - private string $agent; |
|
77 | - |
|
78 | - /** |
|
79 | - * @var string |
|
80 | - */ |
|
81 | - private string $text; |
|
82 | - |
|
83 | - /** |
|
84 | - * @var DateTimeInterface|null |
|
85 | - */ |
|
86 | - private ?DateTimeInterface $date; |
|
87 | - |
|
88 | - /** |
|
89 | - * Constructor of the class |
|
90 | - * |
|
91 | - * @param int $code |
|
92 | - * @param string $agent |
|
93 | - * @param string $text |
|
94 | - * @param DateTimeInterface|null $date |
|
95 | - * |
|
96 | - * @throws InvalidHeaderException |
|
97 | - * If one of arguments isn't valid. |
|
98 | - */ |
|
99 | - public function __construct(int $code, string $agent, string $text, ?DateTimeInterface $date = null) |
|
100 | - { |
|
101 | - $this->validateCode($code); |
|
102 | - $this->validateToken($agent); |
|
103 | - $this->validateQuotedString($text); |
|
104 | - |
|
105 | - $this->code = $code; |
|
106 | - $this->agent = $agent; |
|
107 | - $this->text = $text; |
|
108 | - $this->date = $date; |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * {@inheritdoc} |
|
113 | - */ |
|
114 | - public function getFieldName(): string |
|
115 | - { |
|
116 | - return 'Warning'; |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * {@inheritdoc} |
|
121 | - */ |
|
122 | - public function getFieldValue(): string |
|
123 | - { |
|
124 | - $value = sprintf('%s %s "%s"', $this->code, $this->agent, $this->text); |
|
125 | - |
|
126 | - if (isset($this->date)) { |
|
127 | - $value .= sprintf(' "%s"', $this->formatDateTime($this->date)); |
|
128 | - } |
|
129 | - |
|
130 | - return $value; |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Validates the given code |
|
135 | - * |
|
136 | - * @param int $code |
|
137 | - * |
|
138 | - * @return void |
|
139 | - * |
|
140 | - * @throws InvalidHeaderException |
|
141 | - * If the code isn't valid. |
|
142 | - */ |
|
143 | - private function validateCode(int $code): void |
|
144 | - { |
|
145 | - if (! ($code >= 100 && $code <= 999)) { |
|
146 | - throw new InvalidHeaderException(sprintf( |
|
147 | - 'The code "%2$d" for the header "%1$s" is not valid', |
|
148 | - $this->getFieldName(), |
|
149 | - $code |
|
150 | - )); |
|
151 | - } |
|
152 | - } |
|
33 | + /** |
|
34 | + * @deprecated Use the {@see WarningCode} enum. |
|
35 | + */ |
|
36 | + public const HTTP_WARNING_CODE_RESPONSE_IS_STALE = WarningCode::RESPONSE_IS_STALE; |
|
37 | + |
|
38 | + /** |
|
39 | + * @deprecated Use the {@see WarningCode} enum. |
|
40 | + */ |
|
41 | + public const HTTP_WARNING_CODE_REVALIDATION_FAILED = WarningCode::REVALIDATION_FAILED; |
|
42 | + |
|
43 | + /** |
|
44 | + * @deprecated Use the {@see WarningCode} enum. |
|
45 | + */ |
|
46 | + public const HTTP_WARNING_CODE_DISCONNECTED_OPERATION = WarningCode::DISCONNECTED_OPERATION; |
|
47 | + |
|
48 | + /** |
|
49 | + * @deprecated Use the {@see WarningCode} enum. |
|
50 | + */ |
|
51 | + public const HTTP_WARNING_CODE_HEURISTIC_EXPIRATION = WarningCode::HEURISTIC_EXPIRATION; |
|
52 | + |
|
53 | + /** |
|
54 | + * @deprecated Use the {@see WarningCode} enum. |
|
55 | + */ |
|
56 | + public const HTTP_WARNING_CODE_MISCELLANEOUS_WARNING = WarningCode::MISCELLANEOUS_WARNING; |
|
57 | + |
|
58 | + /** |
|
59 | + * @deprecated Use the {@see WarningCode} enum. |
|
60 | + */ |
|
61 | + public const HTTP_WARNING_CODE_TRANSFORMATION_APPLIED = WarningCode::TRANSFORMATION_APPLIED; |
|
62 | + |
|
63 | + /** |
|
64 | + * @deprecated Use the {@see WarningCode} enum. |
|
65 | + */ |
|
66 | + public const HTTP_WARNING_CODE_MISCELLANEOUS_PERSISTENT_WARNING = WarningCode::MISCELLANEOUS_PERSISTENT_WARNING; |
|
67 | + |
|
68 | + /** |
|
69 | + * @var int |
|
70 | + */ |
|
71 | + private int $code; |
|
72 | + |
|
73 | + /** |
|
74 | + * @var string |
|
75 | + */ |
|
76 | + private string $agent; |
|
77 | + |
|
78 | + /** |
|
79 | + * @var string |
|
80 | + */ |
|
81 | + private string $text; |
|
82 | + |
|
83 | + /** |
|
84 | + * @var DateTimeInterface|null |
|
85 | + */ |
|
86 | + private ?DateTimeInterface $date; |
|
87 | + |
|
88 | + /** |
|
89 | + * Constructor of the class |
|
90 | + * |
|
91 | + * @param int $code |
|
92 | + * @param string $agent |
|
93 | + * @param string $text |
|
94 | + * @param DateTimeInterface|null $date |
|
95 | + * |
|
96 | + * @throws InvalidHeaderException |
|
97 | + * If one of arguments isn't valid. |
|
98 | + */ |
|
99 | + public function __construct(int $code, string $agent, string $text, ?DateTimeInterface $date = null) |
|
100 | + { |
|
101 | + $this->validateCode($code); |
|
102 | + $this->validateToken($agent); |
|
103 | + $this->validateQuotedString($text); |
|
104 | + |
|
105 | + $this->code = $code; |
|
106 | + $this->agent = $agent; |
|
107 | + $this->text = $text; |
|
108 | + $this->date = $date; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * {@inheritdoc} |
|
113 | + */ |
|
114 | + public function getFieldName(): string |
|
115 | + { |
|
116 | + return 'Warning'; |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * {@inheritdoc} |
|
121 | + */ |
|
122 | + public function getFieldValue(): string |
|
123 | + { |
|
124 | + $value = sprintf('%s %s "%s"', $this->code, $this->agent, $this->text); |
|
125 | + |
|
126 | + if (isset($this->date)) { |
|
127 | + $value .= sprintf(' "%s"', $this->formatDateTime($this->date)); |
|
128 | + } |
|
129 | + |
|
130 | + return $value; |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Validates the given code |
|
135 | + * |
|
136 | + * @param int $code |
|
137 | + * |
|
138 | + * @return void |
|
139 | + * |
|
140 | + * @throws InvalidHeaderException |
|
141 | + * If the code isn't valid. |
|
142 | + */ |
|
143 | + private function validateCode(int $code): void |
|
144 | + { |
|
145 | + if (! ($code >= 100 && $code <= 999)) { |
|
146 | + throw new InvalidHeaderException(sprintf( |
|
147 | + 'The code "%2$d" for the header "%1$s" is not valid', |
|
148 | + $this->getFieldName(), |
|
149 | + $code |
|
150 | + )); |
|
151 | + } |
|
152 | + } |
|
153 | 153 | } |
@@ -142,7 +142,7 @@ |
||
142 | 142 | */ |
143 | 143 | private function validateCode(int $code): void |
144 | 144 | { |
145 | - if (! ($code >= 100 && $code <= 999)) { |
|
145 | + if (!($code >= 100 && $code <= 999)) { |
|
146 | 146 | throw new InvalidHeaderException(sprintf( |
147 | 147 | 'The code "%2$d" for the header "%1$s" is not valid', |
148 | 148 | $this->getFieldName(), |
@@ -29,41 +29,41 @@ |
||
29 | 29 | class AllowHeader extends Header |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * @var list<string> |
|
34 | - */ |
|
35 | - private array $methods = []; |
|
32 | + /** |
|
33 | + * @var list<string> |
|
34 | + */ |
|
35 | + private array $methods = []; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Constructor of the class |
|
39 | - * |
|
40 | - * @param string ...$methods |
|
41 | - * |
|
42 | - * @throws InvalidHeaderException |
|
43 | - * If one of the methods isn't valid. |
|
44 | - */ |
|
45 | - public function __construct(string ...$methods) |
|
46 | - { |
|
47 | - $this->validateToken(...$methods); |
|
37 | + /** |
|
38 | + * Constructor of the class |
|
39 | + * |
|
40 | + * @param string ...$methods |
|
41 | + * |
|
42 | + * @throws InvalidHeaderException |
|
43 | + * If one of the methods isn't valid. |
|
44 | + */ |
|
45 | + public function __construct(string ...$methods) |
|
46 | + { |
|
47 | + $this->validateToken(...$methods); |
|
48 | 48 | |
49 | - foreach ($methods as $method) { |
|
50 | - $this->methods[] = strtoupper($method); |
|
51 | - } |
|
52 | - } |
|
49 | + foreach ($methods as $method) { |
|
50 | + $this->methods[] = strtoupper($method); |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * {@inheritdoc} |
|
56 | - */ |
|
57 | - public function getFieldName(): string |
|
58 | - { |
|
59 | - return 'Allow'; |
|
60 | - } |
|
54 | + /** |
|
55 | + * {@inheritdoc} |
|
56 | + */ |
|
57 | + public function getFieldName(): string |
|
58 | + { |
|
59 | + return 'Allow'; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * {@inheritdoc} |
|
64 | - */ |
|
65 | - public function getFieldValue(): string |
|
66 | - { |
|
67 | - return implode(', ', $this->methods); |
|
68 | - } |
|
62 | + /** |
|
63 | + * {@inheritdoc} |
|
64 | + */ |
|
65 | + public function getFieldValue(): string |
|
66 | + { |
|
67 | + return implode(', ', $this->methods); |
|
68 | + } |
|
69 | 69 | } |
@@ -30,111 +30,111 @@ |
||
30 | 30 | class WWWAuthenticateHeader extends Header |
31 | 31 | { |
32 | 32 | |
33 | - /** |
|
34 | - * @deprecated Use the {@see AuthenticationScheme} enum. |
|
35 | - */ |
|
36 | - public const HTTP_AUTHENTICATE_SCHEME_BASIC = AuthenticationScheme::BASIC; |
|
37 | - |
|
38 | - /** |
|
39 | - * @deprecated Use the {@see AuthenticationScheme} enum. |
|
40 | - */ |
|
41 | - public const HTTP_AUTHENTICATE_SCHEME_BEARER = AuthenticationScheme::BEARER; |
|
42 | - |
|
43 | - /** |
|
44 | - * @deprecated Use the {@see AuthenticationScheme} enum. |
|
45 | - */ |
|
46 | - public const HTTP_AUTHENTICATE_SCHEME_DIGEST = AuthenticationScheme::DIGEST; |
|
47 | - |
|
48 | - /** |
|
49 | - * @deprecated Use the {@see AuthenticationScheme} enum. |
|
50 | - */ |
|
51 | - public const HTTP_AUTHENTICATE_SCHEME_HOBA = AuthenticationScheme::HOBA; |
|
52 | - |
|
53 | - /** |
|
54 | - * @deprecated Use the {@see AuthenticationScheme} enum. |
|
55 | - */ |
|
56 | - public const HTTP_AUTHENTICATE_SCHEME_MUTUAL = AuthenticationScheme::MUTUAL; |
|
57 | - |
|
58 | - /** |
|
59 | - * @deprecated Use the {@see AuthenticationScheme} enum. |
|
60 | - */ |
|
61 | - public const HTTP_AUTHENTICATE_SCHEME_NEGOTIATE = AuthenticationScheme::NEGOTIATE; |
|
62 | - |
|
63 | - /** |
|
64 | - * @deprecated Use the {@see AuthenticationScheme} enum. |
|
65 | - */ |
|
66 | - public const HTTP_AUTHENTICATE_SCHEME_OAUTH = AuthenticationScheme::OAUTH; |
|
67 | - |
|
68 | - /** |
|
69 | - * @deprecated Use the {@see AuthenticationScheme} enum. |
|
70 | - */ |
|
71 | - public const HTTP_AUTHENTICATE_SCHEME_SCRAM_SHA_1 = AuthenticationScheme::SCRAM_SHA_1; |
|
72 | - |
|
73 | - /** |
|
74 | - * @deprecated Use the {@see AuthenticationScheme} enum. |
|
75 | - */ |
|
76 | - public const HTTP_AUTHENTICATE_SCHEME_SCRAM_SHA_256 = AuthenticationScheme::SCRAM_SHA_256; |
|
77 | - |
|
78 | - /** |
|
79 | - * @deprecated Use the {@see AuthenticationScheme} enum. |
|
80 | - */ |
|
81 | - public const HTTP_AUTHENTICATE_SCHEME_VAPID = AuthenticationScheme::VAPID; |
|
82 | - |
|
83 | - /** |
|
84 | - * @var string |
|
85 | - */ |
|
86 | - private string $scheme; |
|
87 | - |
|
88 | - /** |
|
89 | - * @var array<string, string> |
|
90 | - */ |
|
91 | - private array $parameters; |
|
92 | - |
|
93 | - /** |
|
94 | - * Constructor of the class |
|
95 | - * |
|
96 | - * @param string $scheme |
|
97 | - * @param array<array-key, mixed> $parameters |
|
98 | - * |
|
99 | - * @throws InvalidHeaderException |
|
100 | - * - If the scheme isn't valid; |
|
101 | - * - If the parameters aren't valid. |
|
102 | - */ |
|
103 | - public function __construct(string $scheme, array $parameters = []) |
|
104 | - { |
|
105 | - $this->validateToken($scheme); |
|
106 | - |
|
107 | - // validate and normalize the parameters... |
|
108 | - $parameters = $this->validateParameters($parameters); |
|
109 | - |
|
110 | - $this->scheme = $scheme; |
|
111 | - $this->parameters = $parameters; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * {@inheritdoc} |
|
116 | - */ |
|
117 | - public function getFieldName(): string |
|
118 | - { |
|
119 | - return 'WWW-Authenticate'; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * {@inheritdoc} |
|
124 | - */ |
|
125 | - public function getFieldValue(): string |
|
126 | - { |
|
127 | - $v = $this->scheme; |
|
128 | - |
|
129 | - $challenge = []; |
|
130 | - foreach ($this->parameters as $name => $value) { |
|
131 | - $challenge[] = sprintf(' %s="%s"', $name, $value); |
|
132 | - } |
|
133 | - |
|
134 | - if (!empty($challenge)) { |
|
135 | - $v .= implode(',', $challenge); |
|
136 | - } |
|
137 | - |
|
138 | - return $v; |
|
139 | - } |
|
33 | + /** |
|
34 | + * @deprecated Use the {@see AuthenticationScheme} enum. |
|
35 | + */ |
|
36 | + public const HTTP_AUTHENTICATE_SCHEME_BASIC = AuthenticationScheme::BASIC; |
|
37 | + |
|
38 | + /** |
|
39 | + * @deprecated Use the {@see AuthenticationScheme} enum. |
|
40 | + */ |
|
41 | + public const HTTP_AUTHENTICATE_SCHEME_BEARER = AuthenticationScheme::BEARER; |
|
42 | + |
|
43 | + /** |
|
44 | + * @deprecated Use the {@see AuthenticationScheme} enum. |
|
45 | + */ |
|
46 | + public const HTTP_AUTHENTICATE_SCHEME_DIGEST = AuthenticationScheme::DIGEST; |
|
47 | + |
|
48 | + /** |
|
49 | + * @deprecated Use the {@see AuthenticationScheme} enum. |
|
50 | + */ |
|
51 | + public const HTTP_AUTHENTICATE_SCHEME_HOBA = AuthenticationScheme::HOBA; |
|
52 | + |
|
53 | + /** |
|
54 | + * @deprecated Use the {@see AuthenticationScheme} enum. |
|
55 | + */ |
|
56 | + public const HTTP_AUTHENTICATE_SCHEME_MUTUAL = AuthenticationScheme::MUTUAL; |
|
57 | + |
|
58 | + /** |
|
59 | + * @deprecated Use the {@see AuthenticationScheme} enum. |
|
60 | + */ |
|
61 | + public const HTTP_AUTHENTICATE_SCHEME_NEGOTIATE = AuthenticationScheme::NEGOTIATE; |
|
62 | + |
|
63 | + /** |
|
64 | + * @deprecated Use the {@see AuthenticationScheme} enum. |
|
65 | + */ |
|
66 | + public const HTTP_AUTHENTICATE_SCHEME_OAUTH = AuthenticationScheme::OAUTH; |
|
67 | + |
|
68 | + /** |
|
69 | + * @deprecated Use the {@see AuthenticationScheme} enum. |
|
70 | + */ |
|
71 | + public const HTTP_AUTHENTICATE_SCHEME_SCRAM_SHA_1 = AuthenticationScheme::SCRAM_SHA_1; |
|
72 | + |
|
73 | + /** |
|
74 | + * @deprecated Use the {@see AuthenticationScheme} enum. |
|
75 | + */ |
|
76 | + public const HTTP_AUTHENTICATE_SCHEME_SCRAM_SHA_256 = AuthenticationScheme::SCRAM_SHA_256; |
|
77 | + |
|
78 | + /** |
|
79 | + * @deprecated Use the {@see AuthenticationScheme} enum. |
|
80 | + */ |
|
81 | + public const HTTP_AUTHENTICATE_SCHEME_VAPID = AuthenticationScheme::VAPID; |
|
82 | + |
|
83 | + /** |
|
84 | + * @var string |
|
85 | + */ |
|
86 | + private string $scheme; |
|
87 | + |
|
88 | + /** |
|
89 | + * @var array<string, string> |
|
90 | + */ |
|
91 | + private array $parameters; |
|
92 | + |
|
93 | + /** |
|
94 | + * Constructor of the class |
|
95 | + * |
|
96 | + * @param string $scheme |
|
97 | + * @param array<array-key, mixed> $parameters |
|
98 | + * |
|
99 | + * @throws InvalidHeaderException |
|
100 | + * - If the scheme isn't valid; |
|
101 | + * - If the parameters aren't valid. |
|
102 | + */ |
|
103 | + public function __construct(string $scheme, array $parameters = []) |
|
104 | + { |
|
105 | + $this->validateToken($scheme); |
|
106 | + |
|
107 | + // validate and normalize the parameters... |
|
108 | + $parameters = $this->validateParameters($parameters); |
|
109 | + |
|
110 | + $this->scheme = $scheme; |
|
111 | + $this->parameters = $parameters; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * {@inheritdoc} |
|
116 | + */ |
|
117 | + public function getFieldName(): string |
|
118 | + { |
|
119 | + return 'WWW-Authenticate'; |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * {@inheritdoc} |
|
124 | + */ |
|
125 | + public function getFieldValue(): string |
|
126 | + { |
|
127 | + $v = $this->scheme; |
|
128 | + |
|
129 | + $challenge = []; |
|
130 | + foreach ($this->parameters as $name => $value) { |
|
131 | + $challenge[] = sprintf(' %s="%s"', $name, $value); |
|
132 | + } |
|
133 | + |
|
134 | + if (!empty($challenge)) { |
|
135 | + $v .= implode(',', $challenge); |
|
136 | + } |
|
137 | + |
|
138 | + return $v; |
|
139 | + } |
|
140 | 140 | } |
@@ -25,37 +25,37 @@ |
||
25 | 25 | class ContentLocationHeader extends Header |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * @var UriInterface |
|
30 | - */ |
|
31 | - private UriInterface $uri; |
|
32 | - |
|
33 | - /** |
|
34 | - * Constructor of the class |
|
35 | - * |
|
36 | - * @param mixed $uri |
|
37 | - * |
|
38 | - * @throws InvalidUriException |
|
39 | - * If the URI isn't valid. |
|
40 | - */ |
|
41 | - public function __construct($uri) |
|
42 | - { |
|
43 | - $this->uri = Uri::create($uri); |
|
44 | - } |
|
45 | - |
|
46 | - /** |
|
47 | - * {@inheritdoc} |
|
48 | - */ |
|
49 | - public function getFieldName(): string |
|
50 | - { |
|
51 | - return 'Content-Location'; |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * {@inheritdoc} |
|
56 | - */ |
|
57 | - public function getFieldValue(): string |
|
58 | - { |
|
59 | - return $this->uri->__toString(); |
|
60 | - } |
|
28 | + /** |
|
29 | + * @var UriInterface |
|
30 | + */ |
|
31 | + private UriInterface $uri; |
|
32 | + |
|
33 | + /** |
|
34 | + * Constructor of the class |
|
35 | + * |
|
36 | + * @param mixed $uri |
|
37 | + * |
|
38 | + * @throws InvalidUriException |
|
39 | + * If the URI isn't valid. |
|
40 | + */ |
|
41 | + public function __construct($uri) |
|
42 | + { |
|
43 | + $this->uri = Uri::create($uri); |
|
44 | + } |
|
45 | + |
|
46 | + /** |
|
47 | + * {@inheritdoc} |
|
48 | + */ |
|
49 | + public function getFieldName(): string |
|
50 | + { |
|
51 | + return 'Content-Location'; |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * {@inheritdoc} |
|
56 | + */ |
|
57 | + public function getFieldValue(): string |
|
58 | + { |
|
59 | + return $this->uri->__toString(); |
|
60 | + } |
|
61 | 61 | } |
@@ -29,53 +29,53 @@ |
||
29 | 29 | class KeepAliveHeader 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 'Keep-Alive'; |
|
59 | - } |
|
53 | + /** |
|
54 | + * {@inheritdoc} |
|
55 | + */ |
|
56 | + public function getFieldName(): string |
|
57 | + { |
|
58 | + return 'Keep-Alive'; |
|
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 | } |
@@ -29,46 +29,46 @@ |
||
29 | 29 | class ClearSiteDataHeader extends Header |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * @var list<string> |
|
34 | - */ |
|
35 | - private array $directives = []; |
|
32 | + /** |
|
33 | + * @var list<string> |
|
34 | + */ |
|
35 | + private array $directives = []; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Constructor of the class |
|
39 | - * |
|
40 | - * @param string ...$directives |
|
41 | - * |
|
42 | - * @throws InvalidHeaderException |
|
43 | - * If one of the directives isn't valid. |
|
44 | - */ |
|
45 | - public function __construct(string ...$directives) |
|
46 | - { |
|
47 | - $this->validateQuotedString(...$directives); |
|
37 | + /** |
|
38 | + * Constructor of the class |
|
39 | + * |
|
40 | + * @param string ...$directives |
|
41 | + * |
|
42 | + * @throws InvalidHeaderException |
|
43 | + * If one of the directives isn't valid. |
|
44 | + */ |
|
45 | + public function __construct(string ...$directives) |
|
46 | + { |
|
47 | + $this->validateQuotedString(...$directives); |
|
48 | 48 | |
49 | - foreach ($directives as $directive) { |
|
50 | - $this->directives[] = $directive; |
|
51 | - } |
|
52 | - } |
|
49 | + foreach ($directives as $directive) { |
|
50 | + $this->directives[] = $directive; |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * {@inheritdoc} |
|
56 | - */ |
|
57 | - public function getFieldName(): string |
|
58 | - { |
|
59 | - return 'Clear-Site-Data'; |
|
60 | - } |
|
54 | + /** |
|
55 | + * {@inheritdoc} |
|
56 | + */ |
|
57 | + public function getFieldName(): string |
|
58 | + { |
|
59 | + return 'Clear-Site-Data'; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * {@inheritdoc} |
|
64 | - */ |
|
65 | - public function getFieldValue(): string |
|
66 | - { |
|
67 | - $segments = []; |
|
68 | - foreach ($this->directives as $directive) { |
|
69 | - $segments[] = sprintf('"%s"', $directive); |
|
70 | - } |
|
62 | + /** |
|
63 | + * {@inheritdoc} |
|
64 | + */ |
|
65 | + public function getFieldValue(): string |
|
66 | + { |
|
67 | + $segments = []; |
|
68 | + foreach ($this->directives as $directive) { |
|
69 | + $segments[] = sprintf('"%s"', $directive); |
|
70 | + } |
|
71 | 71 | |
72 | - return implode(', ', $segments); |
|
73 | - } |
|
72 | + return implode(', ', $segments); |
|
73 | + } |
|
74 | 74 | } |
@@ -31,77 +31,77 @@ |
||
31 | 31 | class AccessControlAllowOriginHeader extends Header |
32 | 32 | { |
33 | 33 | |
34 | - /** |
|
35 | - * @var UriInterface|null |
|
36 | - */ |
|
37 | - private ?UriInterface $uri = null; |
|
34 | + /** |
|
35 | + * @var UriInterface|null |
|
36 | + */ |
|
37 | + private ?UriInterface $uri = null; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Constructor of the class |
|
41 | - * |
|
42 | - * @param mixed $uri |
|
43 | - * |
|
44 | - * @throws InvalidUriException |
|
45 | - * If the URI isn't valid. |
|
46 | - * |
|
47 | - * @throws InvalidHeaderException |
|
48 | - * If the URI isn't valid. |
|
49 | - */ |
|
50 | - public function __construct($uri = null) |
|
51 | - { |
|
52 | - if (isset($uri)) { |
|
53 | - $uri = Uri::create($uri); |
|
54 | - $this->validateUri($uri); |
|
55 | - $this->uri = $uri; |
|
56 | - } |
|
57 | - } |
|
39 | + /** |
|
40 | + * Constructor of the class |
|
41 | + * |
|
42 | + * @param mixed $uri |
|
43 | + * |
|
44 | + * @throws InvalidUriException |
|
45 | + * If the URI isn't valid. |
|
46 | + * |
|
47 | + * @throws InvalidHeaderException |
|
48 | + * If the URI isn't valid. |
|
49 | + */ |
|
50 | + public function __construct($uri = null) |
|
51 | + { |
|
52 | + if (isset($uri)) { |
|
53 | + $uri = Uri::create($uri); |
|
54 | + $this->validateUri($uri); |
|
55 | + $this->uri = $uri; |
|
56 | + } |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * {@inheritdoc} |
|
61 | - */ |
|
62 | - public function getFieldName(): string |
|
63 | - { |
|
64 | - return 'Access-Control-Allow-Origin'; |
|
65 | - } |
|
59 | + /** |
|
60 | + * {@inheritdoc} |
|
61 | + */ |
|
62 | + public function getFieldName(): string |
|
63 | + { |
|
64 | + return 'Access-Control-Allow-Origin'; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * {@inheritdoc} |
|
69 | - */ |
|
70 | - public function getFieldValue(): string |
|
71 | - { |
|
72 | - if (!isset($this->uri)) { |
|
73 | - return '*'; |
|
74 | - } |
|
67 | + /** |
|
68 | + * {@inheritdoc} |
|
69 | + */ |
|
70 | + public function getFieldValue(): string |
|
71 | + { |
|
72 | + if (!isset($this->uri)) { |
|
73 | + return '*'; |
|
74 | + } |
|
75 | 75 | |
76 | - $origin = $this->uri->getScheme() . ':'; |
|
77 | - $origin .= '//' . $this->uri->getHost(); |
|
76 | + $origin = $this->uri->getScheme() . ':'; |
|
77 | + $origin .= '//' . $this->uri->getHost(); |
|
78 | 78 | |
79 | - $port = $this->uri->getPort(); |
|
80 | - if (isset($port)) { |
|
81 | - $origin .= ':' . $port; |
|
82 | - } |
|
79 | + $port = $this->uri->getPort(); |
|
80 | + if (isset($port)) { |
|
81 | + $origin .= ':' . $port; |
|
82 | + } |
|
83 | 83 | |
84 | - return $origin; |
|
85 | - } |
|
84 | + return $origin; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * Validates the given URI |
|
89 | - * |
|
90 | - * @param UriInterface $uri |
|
91 | - * |
|
92 | - * @return void |
|
93 | - * |
|
94 | - * @throws InvalidHeaderException |
|
95 | - * If the URI isn't valid. |
|
96 | - */ |
|
97 | - private function validateUri(UriInterface $uri): void |
|
98 | - { |
|
99 | - if ($uri->getScheme() === '' || $uri->getHost() === '') { |
|
100 | - throw new InvalidHeaderException(sprintf( |
|
101 | - 'The URI "%2$s" for the header "%1$s" is not valid', |
|
102 | - $this->getFieldName(), |
|
103 | - $uri->__toString() |
|
104 | - )); |
|
105 | - } |
|
106 | - } |
|
87 | + /** |
|
88 | + * Validates the given URI |
|
89 | + * |
|
90 | + * @param UriInterface $uri |
|
91 | + * |
|
92 | + * @return void |
|
93 | + * |
|
94 | + * @throws InvalidHeaderException |
|
95 | + * If the URI isn't valid. |
|
96 | + */ |
|
97 | + private function validateUri(UriInterface $uri): void |
|
98 | + { |
|
99 | + if ($uri->getScheme() === '' || $uri->getHost() === '') { |
|
100 | + throw new InvalidHeaderException(sprintf( |
|
101 | + 'The URI "%2$s" for the header "%1$s" is not valid', |
|
102 | + $this->getFieldName(), |
|
103 | + $uri->__toString() |
|
104 | + )); |
|
105 | + } |
|
106 | + } |
|
107 | 107 | } |