Response
in package
Response class that encapsulates the response of an API request.
Tags
Table of Contents
- $header : array<string|int, mixed>
- $payload : string
- __construct() : void
- Response constructor.
- create_from_api_response() : static
- Creates instance from API response body.
- get_header() : string|null
- Fetches a header field.
- get_payload() : array<string|int, mixed>
- Returns payload from the API response.
- get_status_code() : int
- Returns status code from the API response.
- is_successful() : bool
- Checks wether request was successful or not.
- parse_status_line() : array<string|int, mixed>
- Parses a status line.
- parse_header() : array<string|int, mixed>
- Parses raw header into an array.
Properties
$header
private
array<string|int, mixed>
$header
$payload
private
string
$payload
Methods
__construct()
Response constructor.
public
__construct(array<string|int, mixed> $payload, array<string|int, mixed> $header) : void
Parameters
- $payload : array<string|int, mixed>
- $header : array<string|int, mixed>
Return values
void —create_from_api_response()
Creates instance from API response body.
public
static create_from_api_response(string $response, int $header_size) : static
Parameters
- $response : string
- $header_size : int
Return values
static —get_header()
Fetches a header field.
public
get_header(string $field) : string|null
Parameters
- $field : string
Return values
string|null —get_payload()
Returns payload from the API response.
public
get_payload() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_status_code()
Returns status code from the API response.
public
get_status_code() : int
Return values
int —is_successful()
Checks wether request was successful or not.
public
is_successful() : bool
Return values
bool —parse_status_line()
Parses a status line.
protected
static parse_status_line(string $status_line) : array<string|int, mixed>
Parameters
- $status_line : string
Return values
array<string|int, mixed> —parse_header()
Parses raw header into an array.
private
static parse_header( $raw_header) : array<string|int, mixed>
