Total Complexity | 10 |
Total Lines | 66 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | class Response |
||
8 | { |
||
9 | private $rawHeaders; |
||
10 | private $headers; |
||
11 | private $body; |
||
12 | private $error; |
||
13 | |||
14 | public function __construct($rawHeaders, $headers, $body, $error) |
||
15 | { |
||
16 | $this->rawHeaders = $rawHeaders; |
||
17 | $this->headers = $headers; |
||
18 | $this->body = $body; |
||
19 | $this->error = $error; |
||
20 | } |
||
21 | |||
22 | /** @return mixed */ |
||
23 | public function getRawHeaders() |
||
24 | { |
||
25 | $headers = explode("\n", $this->rawHeaders); |
||
26 | $headersArr = []; |
||
27 | |||
28 | foreach ($headers as $header) { |
||
29 | if (!Str::contains($header, ':')) { |
||
30 | continue; |
||
31 | } |
||
32 | |||
33 | [$name, $value] = explode(':', $header, 2); |
||
34 | |||
35 | $headersArr[$name] = $value; |
||
36 | } |
||
37 | |||
38 | return $headersArr; |
||
39 | } |
||
40 | |||
41 | /** @return mixed */ |
||
42 | public function getHeaders() |
||
45 | } |
||
46 | |||
47 | /** @return mixed */ |
||
48 | public function getBody() |
||
51 | } |
||
52 | |||
53 | /** @return bool */ |
||
54 | public function hasBody() |
||
57 | } |
||
58 | |||
59 | /** @return mixed */ |
||
60 | public function getError() |
||
63 | } |
||
64 | |||
65 | /** @return null|int */ |
||
66 | public function getHttpResponseCode() |
||
73 | } |
||
74 | } |
||
75 |