1 | <?php |
||
10 | class ResponseBuilder |
||
11 | { |
||
12 | /** |
||
13 | * The response to be built. |
||
14 | * |
||
15 | * @var ResponseInterface |
||
16 | */ |
||
17 | protected $response; |
||
18 | |||
19 | /** |
||
20 | * Create builder for the given response. |
||
21 | * |
||
22 | * @param ResponseInterface $response |
||
23 | */ |
||
24 | 3 | public function __construct(ResponseInterface $response) |
|
28 | |||
29 | /** |
||
30 | * Return response. |
||
31 | * |
||
32 | * @return ResponseInterface |
||
33 | */ |
||
34 | public function getResponse() |
||
38 | |||
39 | /** |
||
40 | * Add headers represented by an array of header lines. |
||
41 | * |
||
42 | * @param string[] $headers Response headers as array of header lines. |
||
43 | * |
||
44 | * @return $this |
||
45 | * |
||
46 | * @throws \UnexpectedValueException For invalid header values. |
||
47 | * @throws \InvalidArgumentException For invalid status code arguments. |
||
48 | */ |
||
49 | 2 | public function setHeadersFromArray(array $headers) |
|
65 | |||
66 | /** |
||
67 | * Add headers represented by a single string. |
||
68 | * |
||
69 | * @param string $headers Response headers as single string. |
||
70 | * |
||
71 | * @return $this |
||
72 | * |
||
73 | * @throws \InvalidArgumentException if $headers is not a string on object with __toString() |
||
74 | * @throws \UnexpectedValueException For invalid header values. |
||
75 | */ |
||
76 | 1 | public function setHeadersFromString($headers) |
|
94 | |||
95 | /** |
||
96 | * Set response status from a status string. |
||
97 | * |
||
98 | * @param string $statusLine Response status as a string. |
||
99 | * |
||
100 | * @return $this |
||
101 | * |
||
102 | * @throws \InvalidArgumentException For invalid status line. |
||
103 | */ |
||
104 | 2 | public function setStatus($statusLine) |
|
120 | |||
121 | /** |
||
122 | * Add header represented by a string. |
||
123 | * |
||
124 | * @param string $headerLine Response header as a string. |
||
125 | * |
||
126 | * @return $this |
||
127 | * |
||
128 | * @throws \InvalidArgumentException For invalid header names or values. |
||
129 | */ |
||
130 | 2 | public function addHeader($headerLine) |
|
148 | } |
||
149 |