Request
in package
Table of Contents
Properties
- $data : array<string|int, mixed>
Methods
- __construct() : mixed
- Request constructor.
- get() : mixed
- Returns a value for a specified body argument
- getAllData() : mixed
- Returns all body request arguments
- header() : Request
- Method used for setting custom header properties
- headers() : array<string|int, mixed>|string|null
- Returns list of all the header items or a value of a specified key.
- send() : void
- Send response back
- status() : Request
- Sets the header status code for the response
- get_request_headers() : array<string|int, mixed>
- Method used for getting all request headers
- parse_patch_and_put_request_data() : array<string|int, mixed>
- Private method used for parsing request body data for PUT and PATCH requests
- parse_raw_form_data() : array<string|int, mixed>
- Parse raw form input data back into an array
Properties
$data
private
array<string|int, mixed>
$data
Request data
Methods
__construct()
Request constructor.
public
__construct() : mixed
get()
Returns a value for a specified body argument
public
get([string $key = '' ]) : mixed
Parameters
- $key : string = ''
-
Which request body argument to be returned
Return values
mixed —Body argument value or NULL if the argument doesn't exist
getAllData()
Returns all body request arguments
public
getAllData() : mixed
Return values
mixed —All body arguments
header()
Method used for setting custom header properties
public
header(string|array<string|int, mixed>|object $key[, mixed $value = NULL ]) : Request
Soon this option will be removed and should be replaced with a call to the Response class New way of using the Response class: Response::withHeader('header-key', 'header-value');
Parameters
- $key : string|array<string|int, mixed>|object
-
Header key value
- $value : mixed = NULL
-
Header value
Return values
Request —Returns an instance of the Request class so that it can be chained on
headers()
Returns list of all the header items or a value of a specified key.
public
headers([string $key = '' ]) : array<string|int, mixed>|string|null
It will return NULL if the specified key can't be found.
Parameters
- $key : string = ''
-
Name of a specific item in the header list to return the value for
Return values
array<string|int, mixed>|string|null —List of header values or a value of a single item
send()
Send response back
public
send(string|array<string|int, mixed>|object $output[, array<string|int, mixed>|object|null $headers = NULL ]) : void
Soon this option will be removed and should be replaced with a call to the Response class New way of using the Response class: Response::status(200, 'OK')::setBody($output);
Parameters
- $output : string|array<string|int, mixed>|object
-
Value to be outputted as part of the response
- $headers : array<string|int, mixed>|object|null = NULL
-
Optional list of custom header properties to be sent with the response
status()
Sets the header status code for the response
public
status([int $statusCode = 200 ][, string $message = '' ]) : Request
Soon this option will be removed and should be replaced with a call to the Response class New way of using the Response class: Response::withStatus(401, 'Not Authorized');
Parameters
- $statusCode : int = 200
-
Status code to be set for the response
- $message : string = ''
-
Message to be sent int the header alongside the status code
Return values
Request —Returns an instance of the Request class so that it can be chained on
get_request_headers()
Method used for getting all request headers
private
get_request_headers() : array<string|int, mixed>
Return values
array<string|int, mixed> —It will return an array containing all the header values or an empty array
parse_patch_and_put_request_data()
Private method used for parsing request body data for PUT and PATCH requests
private
parse_patch_and_put_request_data() : array<string|int, mixed>
Return values
array<string|int, mixed> —Return an array of request body data
parse_raw_form_data()
Parse raw form input data back into an array
private
parse_raw_form_data() : array<string|int, mixed>
Return values
array<string|int, mixed> —Returns parsed raw form data into an array