HttpClientFactory
in package
Class HttpClientFactory
Configures a Guzzle HTTP client for use with Graph API
Tags
Table of Contents
- CONNECTION_TIMEOUT_SEC = 30
- REQUEST_TIMEOUT_SEC = 100
- $clientConfig : array<string|int, mixed>
- $instance : HttpClientFactory|null
- $nationalCloud : string
- create() : Client
- Creates a Guzzle client with the custom configs provided or a default client if no config was given Creates default Guzzle client if no custom configs were passed
- createAdapter() : HttpClientInterface
- Creates an HttpClientInterface implementation that wraps around a Guzzle client
- setClientConfig() : $this
- Set configuration options for the Guzzle client
- setNationalCloud() : $this
- Set national cloud to be used as the base URL
- __construct() : mixed
- HttpClientFactory constructor.
- getDefaultConfig() : array<string|int, mixed>
- Returns Graph-specific config for Guzzle
- getInstance() : HttpClientFactory
- Returns singleton instance
- mergeConfig() : void
- Merges client defined config array with Graph's default config.
Constants
CONNECTION_TIMEOUT_SEC
public
int
CONNECTION_TIMEOUT_SEC
= 30
REQUEST_TIMEOUT_SEC
public
int
REQUEST_TIMEOUT_SEC
= 100
Properties
$clientConfig
private
static array<string|int, mixed>
$clientConfig
= []
$instance
private
static HttpClientFactory|null
$instance
= null
$nationalCloud
private
static string
$nationalCloud
= MicrosoftGraphCoreNationalCloud::GLOBAL
Methods
create()
Creates a Guzzle client with the custom configs provided or a default client if no config was given Creates default Guzzle client if no custom configs were passed
public
static create() : Client
Return values
Client —createAdapter()
Creates an HttpClientInterface implementation that wraps around a Guzzle client
public
static createAdapter() : HttpClientInterface
Return values
HttpClientInterface —setClientConfig()
Set configuration options for the Guzzle client
public
static setClientConfig(array<string|int, mixed> $config) : $this
Parameters
- $config : array<string|int, mixed>
Return values
$this —setNationalCloud()
Set national cloud to be used as the base URL
public
static setNationalCloud([string $nationalCloud = NationalCloud::GLOBAL ]) : $this
Parameters
- $nationalCloud : string = NationalCloud::GLOBAL
Tags
Return values
$this —__construct()
HttpClientFactory constructor.
private
__construct() : mixed
Return values
mixed —getDefaultConfig()
Returns Graph-specific config for Guzzle
private
static getDefaultConfig() : array<string|int, mixed>
Return values
array<string|int, mixed> —getInstance()
Returns singleton instance
private
static getInstance() : HttpClientFactory
Return values
HttpClientFactory —mergeConfig()
Merges client defined config array with Graph's default config.
private
static mergeConfig() : void
Provides defaults for timeouts and headers if none have been provided. Overrides base_uri.