| Total Complexity | 6 |
| Total Lines | 78 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php namespace Slacky\Http; |
||
| 9 | class SlackResponse implements Response, \JsonSerializable { |
||
| 10 | |||
| 11 | /** |
||
| 12 | * The response body. |
||
| 13 | * |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | protected $body; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * The response headers. |
||
| 20 | * |
||
| 21 | * @var array |
||
| 22 | */ |
||
| 23 | protected $headers; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * The response status code. |
||
| 27 | * |
||
| 28 | * @var integer |
||
| 29 | */ |
||
| 30 | protected $statusCode; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param string $body |
||
| 34 | * @param array $headers |
||
| 35 | * @param integer $statusCode |
||
| 36 | */ |
||
| 37 | public function __construct($body, array $headers = [], $statusCode = 404) |
||
| 38 | { |
||
| 39 | $this->body = json_decode($body, true); |
||
| 40 | $this->headers = $headers; |
||
| 41 | $this->statusCode = $statusCode; |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * {@inheritdoc} |
||
| 46 | */ |
||
| 47 | public function getBody(): array |
||
| 48 | { |
||
| 49 | return $this->body; |
||
|
|
|||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * {@inheritdoc} |
||
| 54 | */ |
||
| 55 | public function getHeaders(): array |
||
| 56 | { |
||
| 57 | return $this->headers; |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * {@inheritdoc} |
||
| 62 | */ |
||
| 63 | public function getStatusCode(): int |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * {@inheritdoc} |
||
| 70 | */ |
||
| 71 | public function jsonSerialize() |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Converts the response to an array. |
||
| 78 | * |
||
| 79 | * @return array |
||
| 80 | */ |
||
| 81 | public function toArray() : array |
||
| 87 | ]; |
||
| 88 | } |
||
| 91 |