Account
11 months ago
Cache
11 months ago
Contracts
11 months ago
Core
11 months ago
Http
11 months ago
Notices
11 months ago
Analyst.php
11 months ago
ApiRequestor.php
11 months ago
ApiResponse.php
11 months ago
Collector.php
11 months ago
Mutator.php
11 months ago
helpers.php
11 months ago
ApiResponse.php
45 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Analyst; |
| 4 | |
| 5 | class ApiResponse |
| 6 | { |
| 7 | /** |
| 8 | * Response headers |
| 9 | * |
| 10 | * @var array |
| 11 | */ |
| 12 | public $headers; |
| 13 | |
| 14 | /** |
| 15 | * Response body |
| 16 | * |
| 17 | * @var mixed |
| 18 | */ |
| 19 | public $body; |
| 20 | |
| 21 | /** |
| 22 | * Status code |
| 23 | * |
| 24 | * @var string |
| 25 | */ |
| 26 | public $code; |
| 27 | |
| 28 | public function __construct($body, $code, $headers) |
| 29 | { |
| 30 | $this->body = $body; |
| 31 | $this->code = $code; |
| 32 | $this->headers = $headers; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Whether status code is successful |
| 37 | * |
| 38 | * @return bool |
| 39 | */ |
| 40 | public function isSuccess() |
| 41 | { |
| 42 | return $this->code >= 200 && $this->code < 300; |
| 43 | } |
| 44 | } |
| 45 |