Documentation

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 = []

$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
throws
BadMethodCallException
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
public

except()

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
Request

get()

public get(array<string|int, mixed> $options) : public
Parameters
$options : array<string|int, mixed>
Return values
public

headers()

Sets the headers

public headers(array<string|int, mixed> $headers) : Request
Parameters
$headers : array<string|int, mixed>
Return values
Request

method()

Sets the HTTP verb

public method([string $method = '' ]) : Request
Parameters
$method : string = ''
Return values
Request

only()

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
Request

path()

public path(array<string|int, mixed> $options) : public
Parameters
$options : array<string|int, mixed>
Return values
public

payload()

Sets the value for data

public payload(mixed $data) : Request
Parameters
$data : mixed
Return values
Request

post()

public post(array<string|int, mixed> $options) : public
Parameters
$options : array<string|int, mixed>
Return values
public

put()

public put(array<string|int, mixed> $options) : public
Parameters
$options : array<string|int, mixed>
Return values
public

send()

Sends or executes a cURL request.

public send() : string|bool

The result will be in JSON format.

Tags
throws
Exception|ValueError
Return values
string|bool

setOptions()

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
Request

filterKeys()

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>
Tags
throws
ValueError
Return values
bool|array<string|int, mixed>

        
On this page

Search results