Total Complexity | 10 |
Total Lines | 63 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class GuzzleResponseBuilder implements ResponseBuilder |
||
10 | { |
||
11 | private int $statusCode = 200; |
||
12 | private array $headers = []; |
||
13 | private string $body = ''; |
||
14 | private array $json = []; |
||
15 | |||
16 | 6 | public function statusCode(int $statusCode): self |
|
17 | { |
||
18 | 6 | $this->statusCode = $statusCode; |
|
19 | |||
20 | 6 | return $this; |
|
21 | } |
||
22 | |||
23 | 1 | public function getStatusCode(): int |
|
24 | { |
||
25 | 1 | return $this->statusCode; |
|
26 | } |
||
27 | |||
28 | 2 | public function headers(array $headers): self |
|
29 | { |
||
30 | 2 | $this->headers = $headers; |
|
31 | |||
32 | 2 | return $this; |
|
33 | } |
||
34 | |||
35 | 1 | public function getHeaders(): array |
|
36 | { |
||
37 | 1 | return $this->headers; |
|
38 | } |
||
39 | |||
40 | 2 | public function getBody(): string |
|
41 | { |
||
42 | 2 | return $this->body; |
|
43 | } |
||
44 | |||
45 | 106 | public function body(string $body): self |
|
46 | { |
||
47 | 106 | $this->body = $body; |
|
48 | 106 | $this->json = []; |
|
49 | |||
50 | 106 | return $this; |
|
51 | } |
||
52 | |||
53 | 2 | public function getJson(): array |
|
54 | { |
||
55 | 2 | return $this->json; |
|
56 | } |
||
57 | |||
58 | 3 | public function json(array $json): self |
|
64 | } |
||
65 | |||
66 | 52 | public function response(): FulfilledPromise |
|
67 | { |
||
68 | 52 | $body = $this->json ? json_encode($this->json, true) : $this->body; |
|
|
|||
69 | |||
72 | ); |
||
73 | } |
||
74 | } |
||
75 |