Total Complexity | 5 |
Total Lines | 71 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
12 | class HttpResponse |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * Set response |
||
17 | * |
||
18 | * @param array $input ["status", "headers", "body", "info", "error"] |
||
19 | * @return HttpResponse |
||
20 | */ |
||
21 | public function setResponse(array $input): self |
||
22 | { |
||
23 | foreach ($input as $key => $value) { |
||
24 | $this->{$key} = $value; |
||
25 | } |
||
26 | return $this; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @var int |
||
31 | */ |
||
32 | public int $status; |
||
33 | |||
34 | /** |
||
35 | * @var array |
||
36 | */ |
||
37 | public array $headers; |
||
38 | |||
39 | /** |
||
40 | * @var bool|string |
||
41 | */ |
||
42 | public bool|string $body; |
||
43 | |||
44 | /** |
||
45 | * @var mixed |
||
46 | */ |
||
47 | public mixed $info; |
||
48 | |||
49 | /** |
||
50 | * @var string |
||
51 | */ |
||
52 | public string $error; |
||
53 | |||
54 | /** |
||
55 | * Get status code |
||
56 | * |
||
57 | * @return int |
||
58 | */ |
||
59 | public function getStatusCode(): int |
||
60 | { |
||
61 | return $this->status; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Get body |
||
66 | * |
||
67 | * @return ?string |
||
68 | */ |
||
69 | public function getBody(): ?string |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Get a key from the response headers |
||
76 | * |
||
77 | * @param string $key |
||
78 | * @return mixed |
||
79 | */ |
||
80 | public function getHeaderLine(string $key): mixed |
||
85 | } |