Auth0-PHP

HttpClient
in package

FinalYes

Table of Contents

Constants

CONTEXT_AUTHENTICATION_CLIENT  : int = 2
CONTEXT_GENERIC_CLIENT  : int = 1
CONTEXT_MANAGEMENT_CLIENT  : int = 3

Properties

$basePath  : string
$configuration  : SdkConfiguration
$context  : int
$headers  : array<string|int, mixed>
$lastRequest  : HttpRequest|null
Instance of most recent HttpRequest.
$mockedResponses  : array<string|int, object>
Mocked responses to pass to HttpRequest instances for testing.

Methods

__construct()  : mixed
HttpClient constructor.
getLastRequest()  : HttpRequest|null
Return a HttpRequest representation of the last built request.
method()  : HttpRequest
Create a new HttpRequest instance.
mockResponse()  : self
Inject a series of Psr\Http\Message\ResponseInterface objects into created HttpRequest clients.
mockResponses()  : self
Inject a series of Psr\Http\Message\ResponseInterface objects into created HttpRequest clients.

Constants

CONTEXT_AUTHENTICATION_CLIENT

public int CONTEXT_AUTHENTICATION_CLIENT = 2

CONTEXT_GENERIC_CLIENT

public int CONTEXT_GENERIC_CLIENT = 1

CONTEXT_MANAGEMENT_CLIENT

public int CONTEXT_MANAGEMENT_CLIENT = 3

Properties

$basePath read-only

private string $basePath = '/'

$context read-only

private int $context = self::CONTEXT_AUTHENTICATION_CLIENT

$headers read-only

private array<string|int, mixed> $headers = []

$mockedResponses

Mocked responses to pass to HttpRequest instances for testing.

private array<string|int, object> $mockedResponses = []

Methods

__construct()

HttpClient constructor.

public __construct(SdkConfiguration $configuration[, int $context = self::CONTEXT_AUTHENTICATION_CLIENT ][, string $basePath = '/' ][, array<string|int, int|string> $headers = [] ]) : mixed
Parameters
$configuration : SdkConfiguration

Required. Base configuration options for the SDK. See the SdkConfiguration class constructor for options.

$context : int = self::CONTEXT_AUTHENTICATION_CLIENT

Required. The context the client is being created under, either CONTEXT_GENERIC_CLIENT, CONTEXT_AUTHENTICATION_CLIENT, or CONTEXT_MANAGEMENT_CLIENT.

$basePath : string = '/'

Optional. The base URI path from which additional pathing and parameters should be appended.

$headers : array<string|int, int|string> = []

Optional. Additional headers to send with the HTTP request.

method()

Create a new HttpRequest instance.

public method(string $method) : HttpRequest
Parameters
$method : string

HTTP method to use (GET, POST, PATCH, etc)

Return values
HttpRequest

mockResponse()

Inject a series of Psr\Http\Message\ResponseInterface objects into created HttpRequest clients.

public mockResponse(ResponseInterface $response[, callable|null $callback = null ][, Exception|null $exception = null ]) : self
Parameters
$response : ResponseInterface
$callback : callable|null = null
$exception : Exception|null = null
Tags
codeCoverageIgnore
Return values
self

mockResponses()

Inject a series of Psr\Http\Message\ResponseInterface objects into created HttpRequest clients.

public mockResponses(array<string|int, Exception}|ResponseInterface$responses) : self
Parameters
$responses : array<string|int, Exception}|ResponseInterface>

an array of ResponseInterface objects, or an array of arrays containing ResponseInterfaces with callbacks

Tags
codeCoverageIgnore
Return values
self
On this page

Search results