Request
in package
FinalYes
Request class handles incoming requests and makes outgoing requests.
Table of Contents
Properties
- $cookies : array<string|int, mixed>
- $headers : array<string|int, mixed>
- $method : string
- $payload : array<string|int, mixed>
- $queryParams : array<string|int, mixed>
- $requestParams : array<string|int, mixed>
- $url : string
- $api : int
- $curlOptions : array<string|int, mixed>
- $except : string|array<string|int, mixed>
- $only : string|array<string|int, mixed>
- $verbs : array<string|int, mixed>
Methods
- __call() : Request
- Magic method to set the request method
- __construct() : mixed
- Initializes request params
- delete() : public
- except() : Request
- Sets the the keys from the request that are not required.
- get() : public
- headers() : Request
- Sets the headers
- method() : Request
- Sets the HTTP verb
- only() : Request
- Sets ONLY the keys from the request that will be sent back.
- path() : public
- payload() : Request
- Sets the value for data
- post() : public
- put() : public
- send() : string|bool
- Sends or executes a cURL request.
- setOptions() : mixed
- Sets all options for cURL call
- url() : Request
- Sets the target URL
- filterKeys() : array<string|int, mixed>
- Filters the ONLY and EXCEPT keys from request array, if there is no filter, it returns the original content from the request array.
- validateOpts() : bool|array<string|int, mixed>
- Validate cURL options and sets basic curlOptions.
Properties
$cookies
public
array<string|int, mixed>
$cookies
= []
$headers
public
array<string|int, mixed>
$headers
= ["Content-Type:application/json"]
$method
public
string
$method
= 'GET'
$payload
public
array<string|int, mixed>
$payload
= []
$queryParams
public
array<string|int, mixed>
$queryParams
= []
$requestParams
public
array<string|int, mixed>
$requestParams
= []
$url
public
string
$url
$api
private
static int
$api
= 0
$curlOptions
private
array<string|int, mixed>
$curlOptions
= []
$except
private
string|array<string|int, mixed>
$except
= []
$only
private
string|array<string|int, mixed>
$only
= []
$
$verbs
private
array<string|int, mixed>
$verbs
= ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'FILES']
Methods
__call()
Magic method to set the request method
public
__call(string $verb, mixed $args) : Request
Parameters
- $verb : string
- $args : mixed
Tags
Return values
Request__construct()
Initializes request params
public
__construct() : mixed
delete()
public
delete(array<string|int, mixed> $options) : public
Parameters
- $options : array<string|int, mixed>
Return values
publicexcept()
Sets the the keys from the request that are not required.
public
except(string|array<string|int, mixed> $keys) : Request
Parameters
- $keys : string|array<string|int, mixed>
Return values
Requestget()
public
get(array<string|int, mixed> $options) : public
Parameters
- $options : array<string|int, mixed>
Return values
publicheaders()
Sets the headers
public
headers(array<string|int, mixed> $headers) : Request
Parameters
- $headers : array<string|int, mixed>
Return values
Requestmethod()
Sets the HTTP verb
public
method([string $method = '' ]) : Request
Parameters
- $method : string = ''
Return values
Requestonly()
Sets ONLY the keys from the request that will be sent back.
public
only(string|array<string|int, mixed> $keys) : Request
Parameters
- $keys : string|array<string|int, mixed>
Return values
Requestpath()
public
path(array<string|int, mixed> $options) : public
Parameters
- $options : array<string|int, mixed>
Return values
publicpayload()
Sets the value for data
public
payload(mixed $data) : Request
Parameters
- $data : mixed
Return values
Requestpost()
public
post(array<string|int, mixed> $options) : public
Parameters
- $options : array<string|int, mixed>
Return values
publicput()
public
put(array<string|int, mixed> $options) : public
Parameters
- $options : array<string|int, mixed>
Return values
publicsend()
Sends or executes a cURL request.
public
send() : string|bool
The result will be in JSON format.
Tags
Return values
string|boolsetOptions()
Sets all options for cURL call
public
setOptions(mixed $opts, array<string|int, mixed> $keys) : mixed
Parameters
- $opts : mixed
- $keys : array<string|int, mixed>
url()
Sets the target URL
public
url(string $url) : Request
Parameters
- $url : string
Return values
RequestfilterKeys()
Filters the ONLY and EXCEPT keys from request array, if there is no filter, it returns the original content from the request array.
private
filterKeys(array<string|int, mixed> $content, array<string|int, mixed> $keys) : array<string|int, mixed>
Parameters
- $content : array<string|int, mixed>
- $keys : array<string|int, mixed>
Return values
array<string|int, mixed>validateOpts()
Validate cURL options and sets basic curlOptions.
private
validateOpts() : bool|array<string|int, mixed>