| 1 | <?php |
||
| 5 | class Response |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * HTTP Status code |
||
| 9 | * |
||
| 10 | * @int |
||
| 11 | */ |
||
| 12 | protected $status; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Headers. |
||
| 16 | * |
||
| 17 | * @var array |
||
| 18 | */ |
||
| 19 | protected $headers; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Contents. |
||
| 23 | * |
||
| 24 | * @var string |
||
| 25 | */ |
||
| 26 | protected $body; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Assign dependencies. |
||
| 30 | * |
||
| 31 | * @param int $status |
||
| 32 | * @param array $headers |
||
| 33 | * @param string $body |
||
| 34 | */ |
||
| 35 | 24 | public function __construct($status = 200, array $headers = [], $body = null) |
|
| 41 | |||
| 42 | /** |
||
| 43 | * Extracts the relevant content from the response. |
||
| 44 | * |
||
| 45 | * @return array|mixed |
||
| 46 | */ |
||
| 47 | 2 | public function result() |
|
| 58 | |||
| 59 | /** |
||
| 60 | * Get query limit headers. |
||
| 61 | * |
||
| 62 | * @param array $limits |
||
| 63 | * |
||
| 64 | * @return array |
||
| 65 | */ |
||
| 66 | 2 | public function limits(array $limits = []) |
|
| 80 | |||
| 81 | /** |
||
| 82 | * Get body. |
||
| 83 | * |
||
| 84 | * @return string |
||
| 85 | */ |
||
| 86 | 4 | public function getBody() |
|
| 90 | |||
| 91 | /** |
||
| 92 | * Get HTTP status code. |
||
| 93 | * |
||
| 94 | * @return string |
||
| 95 | */ |
||
| 96 | 4 | public function getStatus() |
|
| 100 | |||
| 101 | /** |
||
| 102 | * Get response headers. |
||
| 103 | * |
||
| 104 | * @return array |
||
| 105 | */ |
||
| 106 | 2 | public function getHeaders() |
|
| 110 | |||
| 111 | /** |
||
| 112 | * Get a response header by key. |
||
| 113 | * |
||
| 114 | * @param string $key |
||
| 115 | * |
||
| 116 | * @return string |
||
| 117 | */ |
||
| 118 | 6 | public function getHeader($key) |
|
| 124 | } |
||
| 125 |