1 | <?php |
||
20 | class GenericHeader implements HeaderInterface |
||
21 | { |
||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $fieldName; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | private $fieldValue; |
||
31 | |||
32 | /** |
||
33 | * Constructor. |
||
34 | * |
||
35 | * @param string $fieldName |
||
36 | * @param string $fieldValue |
||
37 | */ |
||
38 | public function __construct($fieldName, $fieldValue) |
||
43 | |||
44 | /** |
||
45 | * Factory create GenericHeader from string representation. |
||
46 | * |
||
47 | * @param string $headerLine |
||
48 | * |
||
49 | * @return $this |
||
50 | */ |
||
51 | public static function fromString($headerLine) |
||
57 | |||
58 | /** |
||
59 | * Split name and value by header line. |
||
60 | * |
||
61 | * @param string $headerLine |
||
62 | * |
||
63 | * @return array |
||
64 | * |
||
65 | * @throws InvalidArgumentException |
||
66 | */ |
||
67 | public static function splitHeaderLine($headerLine) |
||
86 | |||
87 | /** |
||
88 | * Compute delta seconds. |
||
89 | * |
||
90 | * @param int $deltaSeconds |
||
91 | * |
||
92 | * @return int |
||
93 | */ |
||
94 | public static function computeDeltaSeconds($deltaSeconds) |
||
107 | |||
108 | /** |
||
109 | * Check if header value is valid based on RFC 7230. |
||
110 | * Borrowed from Zend-Framework. |
||
111 | * |
||
112 | * @see http://en.wikipedia.org/wiki/HTTP_response_splitting |
||
113 | * |
||
114 | * @param string $value |
||
115 | * |
||
116 | * @return bool |
||
117 | */ |
||
118 | public static function isValidHeaderValue($value) |
||
135 | |||
136 | /** |
||
137 | * Assert empty header field name. |
||
138 | * |
||
139 | * @param string $headerName |
||
140 | */ |
||
141 | public static function assertEmptyHeaderFieldName($headerName) |
||
150 | |||
151 | /** |
||
152 | * Assert match header field name. |
||
153 | * |
||
154 | * @param string $fieldName |
||
155 | * @param string $givenFieldName |
||
156 | * |
||
157 | * @throws InvalidHeaderValueException |
||
158 | */ |
||
159 | public static function assertHeaderFieldName($fieldName, $givenFieldName) |
||
165 | |||
166 | /** |
||
167 | * Assert header value. |
||
168 | * |
||
169 | * @param string $value |
||
170 | * |
||
171 | * @throws InvalidHeaderValueException |
||
172 | */ |
||
173 | public static function assertHeaderValue($value) |
||
179 | |||
180 | /** |
||
181 | * Get header field name. |
||
182 | * |
||
183 | * @return string |
||
184 | */ |
||
185 | public function getFieldName() |
||
189 | |||
190 | /** |
||
191 | * Get header field value. |
||
192 | * |
||
193 | * @return mixed |
||
194 | */ |
||
195 | public function getFieldValue() |
||
199 | |||
200 | /** |
||
201 | * Cast header to string. |
||
202 | * |
||
203 | * @return string |
||
204 | */ |
||
205 | public function __toString() |
||
209 | } |
||
210 |