1: | <?php |
2: | namespace Worldline\Acquiring\Sdk\Communication; |
3: | |
4: | /** |
5: | * Class ResponseBuilder |
6: | * |
7: | * @package Worldline\Acquiring\Sdk\Communication |
8: | */ |
9: | class ResponseBuilder |
10: | { |
11: | /** @var int */ |
12: | private $httpStatusCode; |
13: | |
14: | /** @var array */ |
15: | private $headers; |
16: | |
17: | /** @var string */ |
18: | private $body = ''; |
19: | |
20: | /** |
21: | * @param int $httpStatusCode |
22: | */ |
23: | public function setHttpStatusCode($httpStatusCode) |
24: | { |
25: | $this->httpStatusCode = $httpStatusCode; |
26: | } |
27: | |
28: | /** |
29: | * @param array $headers |
30: | */ |
31: | public function setHeaders(array $headers) |
32: | { |
33: | $this->headers = $headers; |
34: | } |
35: | |
36: | /** |
37: | * @param string $data |
38: | */ |
39: | public function appendBody($data) |
40: | { |
41: | $this->body .= $data; |
42: | } |
43: | |
44: | /** |
45: | * @param string $body |
46: | */ |
47: | public function setBody($body) |
48: | { |
49: | $this->body = $body; |
50: | } |
51: | |
52: | /** |
53: | * @return ConnectionResponse |
54: | */ |
55: | public function getResponse() |
56: | { |
57: | return new ConnectionResponse($this->httpStatusCode, $this->headers, $this->body); |
58: | } |
59: | } |
60: |