Auth0-PHP

HttpResponse
in package

FinalYes

Table of Contents

Methods

decodeContent()  : mixed
Extract the content from an HTTP response and parse as JSON (ResponseInterface).
getContent()  : string
Extract the content from an HTTP response (ResponseInterface).
getHeaders()  : array<string|int, array<string|int, string>>
Extract the headers from an HTTP response (ResponseInterface).
getStatusCode()  : int
Extract the status code from an HTTP response (ResponseInterface).
parseQuotaBuckets()  : array<string, array{quota: null|int, remaining: null|int, resetAfter: null|int}>
Helper function to parse "b=per_hour;q=100;r=99;t=1,b=per_day;q=300;r=299;t=1" into an array like: [ 'per_hour' => [ 'quota' => 100, 'remaining' => 99, 'resetAfter' => 1 ], 'per_day' => [ 'quota' => 300, 'remaining' => 299, 'resetAfter' => 1 ] ].
parseQuotaHeaders()  : array{client?: array, organization?: array, retryAfter?: int, rateLimit?: array{limit?: int, remaining?: int, reset?: int}}
Parse Auth0's quota headers into the desired 'client'/'organization' structure.
wasSuccessful()  : bool
Returns true when the ResponseInterface identifies a 200 status code; otherwise false.

Methods

decodeContent()

Extract the content from an HTTP response and parse as JSON (ResponseInterface).

public static decodeContent(ResponseInterface $response) : mixed
Parameters
$response : ResponseInterface

a ResponseInterface instance to extract from

Tags
throws
JsonException

when JSON decoding fails

getContent()

Extract the content from an HTTP response (ResponseInterface).

public static getContent(ResponseInterface $response) : string
Parameters
$response : ResponseInterface

a ResponseInterface instance to extract from

Tags
psalm-suppress

RedundantConditionGivenDocblockType

Return values
string

getHeaders()

Extract the headers from an HTTP response (ResponseInterface).

public static getHeaders(ResponseInterface $response) : array<string|int, array<string|int, string>>
Parameters
$response : ResponseInterface

a ResponseInterface instance to extract from

Return values
array<string|int, array<string|int, string>>

getStatusCode()

Extract the status code from an HTTP response (ResponseInterface).

public static getStatusCode(ResponseInterface $response) : int
Parameters
$response : ResponseInterface

a ResponseInterface instance to extract from

Return values
int

parseQuotaBuckets()

Helper function to parse "b=per_hour;q=100;r=99;t=1,b=per_day;q=300;r=299;t=1" into an array like: [ 'per_hour' => [ 'quota' => 100, 'remaining' => 99, 'resetAfter' => 1 ], 'per_day' => [ 'quota' => 300, 'remaining' => 299, 'resetAfter' => 1 ] ].

public static parseQuotaBuckets(string $rawValue) : array<string, array{quota: null|int, remaining: null|int, resetAfter: null|int}>
Parameters
$rawValue : string
Return values
array<string, array{quota: null|int, remaining: null|int, resetAfter: null|int}>

parseQuotaHeaders()

Parse Auth0's quota headers into the desired 'client'/'organization' structure.

public static parseQuotaHeaders(ResponseInterface $response) : array{client?: array, organization?: array, retryAfter?: int, rateLimit?: array{limit?: int, remaining?: int, reset?: int}}

The returned array looks like: [ 'client' => [ 'per_hour' => [ 'quota' => ..., 'remaining' => ..., 'resetAfter' => ... ], 'per_day' => [ 'quota' => ..., 'remaining' => ..., 'resetAfter' => ... ], ], 'organization' => [ 'per_hour' => [...], 'per_day' => [...], ] ].

Buckets or keys missing from the header won't appear in the array.

Parameters
$response : ResponseInterface

a ResponseInterface instance to extract from

Return values
array{client?: array, organization?: array, retryAfter?: int, rateLimit?: array{limit?: int, remaining?: int, reset?: int}}

wasSuccessful()

Returns true when the ResponseInterface identifies a 200 status code; otherwise false.

public static wasSuccessful(ResponseInterface $response[, int $expectedStatusCode = 200 ]) : bool
Parameters
$response : ResponseInterface

a ResponseInterface instance to extract from

$expectedStatusCode : int = 200

Optional. The status code expected to consider the request successful. Defaults to 200.

Return values
bool
On this page

Search results