1 | <?php |
||
22 | class Message implements MessageInterface |
||
23 | { |
||
24 | const DEFAULT_VERSION = '1.1'; |
||
25 | const VERSION_DELIMITER = 'HTTP/'; |
||
26 | const HEADER_DELIMITER = ': '; |
||
27 | const HEADER_VALUE_DELIMITER = ','; |
||
28 | |||
29 | /** @var string The version. */ |
||
30 | private $version; |
||
31 | |||
32 | /** @var array The header names. */ |
||
33 | private $headerNames; |
||
34 | |||
35 | /** @var array The headers. */ |
||
36 | private $headers; |
||
37 | |||
38 | /** @var StreamInterface The body. */ |
||
39 | private $body; |
||
40 | |||
41 | /** |
||
42 | * Construct a Message object with the given version, headers & body. |
||
43 | * |
||
44 | * @param string $version = self::DEFAULT_VERSION |
||
45 | * @param array $headers = [] |
||
46 | * @param StreamInterface|null $body = null |
||
47 | */ |
||
48 | 42 | public function __construct($version = self::DEFAULT_VERSION, array $headers = [], StreamInterface $body = null) |
|
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | */ |
||
62 | 3 | public function getProtocolVersion() |
|
66 | |||
67 | /** |
||
68 | * Set the protocol version. |
||
69 | * |
||
70 | * @param string $version |
||
71 | * @return $this |
||
72 | */ |
||
73 | 42 | private function setProtocolVersion($version) |
|
79 | |||
80 | /** |
||
81 | * {@inheritdoc} |
||
82 | */ |
||
83 | 1 | public function withProtocolVersion($version) |
|
89 | |||
90 | /** |
||
91 | * {@inheritdoc} |
||
92 | */ |
||
93 | 2 | public function getHeaders() |
|
97 | |||
98 | /** |
||
99 | * Set the headers. |
||
100 | * |
||
101 | * @param array $headers |
||
102 | * @return $this |
||
103 | */ |
||
104 | 42 | private function setHeaders(array $headers) |
|
115 | |||
116 | /** |
||
117 | * {@inheritdoc} |
||
118 | */ |
||
119 | 12 | public function hasHeader($name) |
|
123 | |||
124 | /** |
||
125 | * {@inheritdoc} |
||
126 | */ |
||
127 | 10 | public function getHeader($name) |
|
135 | |||
136 | /** |
||
137 | * {@inheritdoc} |
||
138 | */ |
||
139 | 4 | public function getHeaderLine($name) |
|
147 | |||
148 | /** |
||
149 | * Set the header. |
||
150 | * |
||
151 | * @param string $name |
||
152 | * @param string|string[] $value |
||
153 | * @return $this |
||
154 | */ |
||
155 | 18 | protected function setHeader($name, $value) |
|
166 | |||
167 | /** |
||
168 | * {@inheritdoc} |
||
169 | */ |
||
170 | 5 | public function withHeader($name, $value) |
|
176 | |||
177 | /** |
||
178 | * Add the header. |
||
179 | * |
||
180 | * @param string $name |
||
181 | * @param string|string[] $value |
||
182 | * @return $this |
||
183 | */ |
||
184 | 3 | private function addHeader($name, $value) |
|
200 | |||
201 | /** |
||
202 | * {@inheritdoc} |
||
203 | */ |
||
204 | 3 | public function withAddedHeader($name, $value) |
|
210 | |||
211 | /** |
||
212 | * Remove the header. |
||
213 | * |
||
214 | * @param string $name |
||
215 | * @return $this |
||
216 | */ |
||
217 | 1 | private function removeHeader($name) |
|
227 | |||
228 | /** |
||
229 | * {@inheritdoc} |
||
230 | */ |
||
231 | 1 | public function withoutHeader($name) |
|
237 | |||
238 | /** |
||
239 | * {@inheritdoc} |
||
240 | */ |
||
241 | 4 | public function getBody() |
|
245 | |||
246 | /** |
||
247 | * Sets the body. |
||
248 | * |
||
249 | * @param StreamInterface $body |
||
250 | * @return $this |
||
251 | */ |
||
252 | 42 | private function setBody(StreamInterface $body) |
|
258 | |||
259 | /** |
||
260 | * {@inheritdoc} |
||
261 | */ |
||
262 | 2 | public function withBody(StreamInterface $body) |
|
268 | } |
||
269 |