Menu

## HttpClientFactory
in package

HttpClientFactory.php : 29

Class HttpClientFactory

Configures a Guzzle HTTP client for use with Graph API

##### Tags

copyright

  2021 Microsoft Corporation

license

  https://opensource.org/licenses/MIT MIT License

link
  https://developer.microsoft.com/graph

### 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

HttpClientFactory.php : 34
`public int CONNECTION_TIMEOUT_SEC = 30`

#### REQUEST_TIMEOUT_SEC

HttpClientFactory.php : 39
`public int REQUEST_TIMEOUT_SEC = 100`

### Properties

#### $clientConfig

HttpClientFactory.php : 49
`private static array<string|int, mixed> $clientConfig = []`

#### $instance

HttpClientFactory.php : 54
`private static HttpClientFactory|null $instance = null`

#### $nationalCloud

HttpClientFactory.php : 44
`private static string $nationalCloud = MicrosoftGraphCoreNationalCloud::GLOBAL`

### Methods

#### create()

HttpClientFactory.php : 105

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()

HttpClientFactory.php : 118

Creates an HttpClientInterface implementation that wraps around a Guzzle client

`public static createAdapter() : HttpClientInterface`

##### Return values

HttpClientInterface —

#### setClientConfig()

HttpClientFactory.php : 94

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()

HttpClientFactory.php : 80

Set national cloud to be used as the base URL

`public static setNationalCloud([string $nationalCloud = NationalCloud::GLOBAL ]) : $this`

##### Parameters

$nationalCloud : string = NationalCloud::GLOBAL

##### Tags

throws
  GraphClientException

  if $nationalCloud is empty or an invalid national cloud Host

##### Return values

$this —

#### __construct()

HttpClientFactory.php : 59

HttpClientFactory constructor.

`private __construct() : mixed`

##### Return values

mixed —

#### getDefaultConfig()

HttpClientFactory.php : 141

Returns Graph-specific config for Guzzle

`private static getDefaultConfig() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

#### getInstance()

HttpClientFactory.php : 66

Returns singleton instance

`private static getInstance() : HttpClientFactory`

##### Return values

HttpClientFactory —

#### mergeConfig()

HttpClientFactory.php : 158

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.

##### Return values

void —

## Search results