Client
in package
implements
Http
Table of Contents
Interfaces
Properties
- $baseUrl : non-empty-string
- $headers : array<string, string|array<string|int, string>>
- $http : ClientInterface
- $json : Json
- $requestFactory : RequestFactoryInterface
- $streamFactory : StreamFactoryInterface
Methods
- __construct() : mixed
- delete() : mixed
- get() : mixed
- patch() : mixed
- post() : mixed
- put() : mixed
- buildQueryString() : string
- execute() : mixed
- isJSONResponse() : bool
- Checks if any of the header values indicate a JSON response.
- parseResponse() : mixed
Properties
$baseUrl
private
non-empty-string
$baseUrl
$headers
private
array<string, string|array<string|int, string>>
$headers
$http
private
ClientInterface
$http
$json
private
Json
$json
$requestFactory
private
RequestFactoryInterface
$requestFactory
$streamFactory
private
StreamFactoryInterface
$streamFactory
Methods
__construct()
public
__construct(non-empty-string $url[, string|null $apiKey = null ][, ClientInterface|null $httpClient = null ][, RequestFactoryInterface|null $reqFactory = null ][, array<int, string> $clientAgents = [] ][, StreamFactoryInterface|null $streamFactory = null ]) : mixed
Parameters
- $url : non-empty-string
- $apiKey : string|null = null
- $httpClient : ClientInterface|null = null
- $reqFactory : RequestFactoryInterface|null = null
- $clientAgents : array<int, string> = []
- $streamFactory : StreamFactoryInterface|null = null
delete()
public
delete(string $path[, array<string|int, mixed> $query = [] ]) : mixed
Parameters
- $path : string
- $query : array<string|int, mixed> = []
get()
public
get(string $path[, array<string|int, mixed> $query = [] ]) : mixed
Parameters
- $path : string
- $query : array<string|int, mixed> = []
Tags
patch()
public
patch(string $path[, mixed $body = null ][, array<string|int, mixed> $query = [] ]) : mixed
Parameters
- $path : string
- $body : mixed = null
- $query : array<string|int, mixed> = []
post()
public
post(string $path[, mixed $body = null ][, array<string|int, mixed> $query = [] ][, non-empty-string|null $contentType = null ]) : mixed
Parameters
- $path : string
- $body : mixed = null
- $query : array<string|int, mixed> = []
- $contentType : non-empty-string|null = null
Tags
put()
public
put(string $path[, mixed $body = null ][, array<string|int, mixed> $query = [] ][, non-empty-string|null $contentType = null ]) : mixed
Parameters
- $path : string
- $body : mixed = null
- $query : array<string|int, mixed> = []
- $contentType : non-empty-string|null = null
Tags
buildQueryString()
private
buildQueryString([array<string|int, mixed> $queryParams = [] ]) : string
Parameters
- $queryParams : array<string|int, mixed> = []
Return values
stringexecute()
private
execute(RequestInterface $request[, array<string, string|array<string|int, string>> $headers = [] ]) : mixed
Parameters
- $request : RequestInterface
- $headers : array<string, string|array<string|int, string>> = []
Tags
isJSONResponse()
Checks if any of the header values indicate a JSON response.
private
isJSONResponse(array<string|int, mixed> $headerValues) : bool
Parameters
- $headerValues : array<string|int, mixed>
-
the array of header values to check
Return values
bool —true if any header value contains 'application/json', otherwise false
parseResponse()
private
parseResponse(ResponseInterface $response) : mixed
Parameters
- $response : ResponseInterface