Menu

## Response
in package

Response.php : 25

Response class that encapsulates the response of an API request.

##### Tags

category

  Class

author

  Daniel Muenter info@msltns.com

version
  0.0.1
since
  0.0.1
license

  GPL 3 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 3, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

### 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

Response.php : 30
`private array<string|int, mixed> $header`

#### $payload

Response.php : 35
`private string $payload`

### Methods

#### __construct()

Response.php : 44

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()

Response.php : 56

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()

Response.php : 120

Fetches a header field.

`public get_header(string $field) : string|null`

##### Parameters

$field : string

##### Return values

string|null —

#### get_payload()

Response.php : 135

Returns payload from the API response.

`public get_payload() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

#### get_status_code()

Response.php : 144

Returns status code from the API response.

`public get_status_code() : int`

##### Return values

int —

#### is_successful()

Response.php : 153

Checks wether request was successful or not.

`public is_successful() : bool`

##### Return values

bool —

#### parse_status_line()

Response.php : 73

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()

Response.php : 89

Parses raw header into an array.

`private static parse_header( $raw_header) : array<string|int, mixed>`

##### Parameters

$raw_header :

##### Return values

array<string|int, mixed> —

## Search results