Account
2 years ago
Cache
2 years ago
Contracts
2 years ago
Core
2 years ago
Http
2 years ago
Notices
2 years ago
Analyst.php
2 years ago
ApiRequestor.php
2 years ago
ApiResponse.php
2 years ago
Collector.php
2 years ago
Mutator.php
2 years ago
helpers.php
2 years 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 |