Config
in package
Table of Contents
Properties
- $accountId : int
- $activeContext : string
- $apiVersion : string|null
- $appKey : string|null
- $baseUrl : string|null
- $contexts : array<string, array{api_version?: string, timeout?: int, app_key?: string, base_url?: string, account_id?: int}>
- $timeout : int|null
Methods
- autoDetect() : void
- Auto-detect configuration from environment variables.
- debugConfig() : array<string, mixed>
- Debug the configuration for a specific context.
- getAccountId() : int
- Get the account ID.
- getAllContexts() : array<string|int, string>
- Get all configured contexts.
- getApiKey() : string|null
- Get the API key (alias for getAppKey for common naming).
- getApiVersion() : string|null
- Get the API version.
- getAppKey() : string|null
- Get the application key.
- getBaseUrl() : string|null
- Get the base URL for API requests.
- getContext() : string
- Get the currently active context.
- getTimeout() : int|null
- Get the timeout for API requests.
- hasAccountIdConfigured() : bool
- Check if an account ID has been explicitly configured for a context.
- resetContext() : void
- Reset a specific context, removing all its configuration.
- setAccountId() : void
- Set the account ID.
- setApiKey() : void
- Set the API key (alias for setAppKey for common naming).
- setApiVersion() : void
- Set the API version.
- setAppKey() : void
- Set the application key.
- setBaseUrl() : void
- Set the base URL for API requests.
- setContext() : void
- Set the active context for configuration.
- setTimeout() : void
- Set the timeout for API requests.
- validate() : void
- Validate the configuration for a specific context.
- syncLegacyValues() : void
- Synchronize legacy static properties with active context values.
Properties
$accountId
private
static int
$accountId
= 1
$activeContext
private
static string
$activeContext
= 'default'
$apiVersion
private
static string|null
$apiVersion
= 'v1'
$appKey
private
static string|null
$appKey
= null
$baseUrl
private
static string|null
$baseUrl
= null
$contexts
private
static array<string, array{api_version?: string, timeout?: int, app_key?: string, base_url?: string, account_id?: int}>
$contexts
= []
$timeout
private
static int|null
$timeout
= 30
Methods
autoDetect()
Auto-detect configuration from environment variables.
public
static autoDetect([string|null $context = null ]) : void
Parameters
- $context : string|null = null
-
The context to set configuration for. If null, uses active context.
Tags
debugConfig()
Debug the configuration for a specific context.
public
static debugConfig([string|null $context = null ]) : array<string, mixed>
Parameters
- $context : string|null = null
-
The context to debug. If null, uses active context.
Return values
array<string, mixed> —Configuration details for debugging.
getAccountId()
Get the account ID.
public
static getAccountId([string|null $context = null ]) : int
Parameters
- $context : string|null = null
-
The context to get the account ID from. If null, uses active context.
Return values
int —The account ID.
getAllContexts()
Get all configured contexts.
public
static getAllContexts() : array<string|int, string>
Return values
array<string|int, string> —List of context names.
getApiKey()
Get the API key (alias for getAppKey for common naming).
public
static getApiKey([string|null $context = null ]) : string|null
Parameters
- $context : string|null = null
-
The context to get the key from. If null, uses active context.
Return values
string|null —The API key or null if not set.
getApiVersion()
Get the API version.
public
static getApiVersion([string|null $context = null ]) : string|null
Parameters
- $context : string|null = null
-
The context to get the version from. If null, uses active context.
Return values
string|null —The API version or null if not set.
getAppKey()
Get the application key.
public
static getAppKey([string|null $context = null ]) : string|null
Parameters
- $context : string|null = null
-
The context to get the key from. If null, uses active context.
Return values
string|null —The application key or null if not set.
getBaseUrl()
Get the base URL for API requests.
public
static getBaseUrl([string|null $context = null ]) : string|null
Parameters
- $context : string|null = null
-
The context to get the URL from. If null, uses active context.
Return values
string|null —The base URL or null if not set.
getContext()
Get the currently active context.
public
static getContext() : string
Return values
string —The active context name.
getTimeout()
Get the timeout for API requests.
public
static getTimeout([string|null $context = null ]) : int|null
Parameters
- $context : string|null = null
-
The context to get the timeout from. If null, uses active context.
Return values
int|null —The timeout in seconds or null if not set.
hasAccountIdConfigured()
Check if an account ID has been explicitly configured for a context.
public
static hasAccountIdConfigured([string|null $context = null ]) : bool
Parameters
- $context : string|null = null
-
The context to check. If null, uses active context.
Return values
bool —True if account ID is explicitly configured, false if using default.
resetContext()
Reset a specific context, removing all its configuration.
public
static resetContext(string $context) : void
Parameters
- $context : string
-
The context to reset.
setAccountId()
Set the account ID.
public
static setAccountId(int $accountId[, string|null $context = null ]) : void
Parameters
- $accountId : int
-
The account ID.
- $context : string|null = null
-
The context to set the account ID for. If null, uses active context.
setApiKey()
Set the API key (alias for setAppKey for common naming).
public
static setApiKey(string $key[, string|null $context = null ]) : void
Parameters
- $key : string
-
The API key.
- $context : string|null = null
-
The context to set the key for. If null, uses active context.
setApiVersion()
Set the API version.
public
static setApiVersion(string $version[, string|null $context = null ]) : void
Parameters
- $version : string
-
The API version.
- $context : string|null = null
-
The context to set the version for. If null, uses active context.
setAppKey()
Set the application key.
public
static setAppKey(string $key[, string|null $context = null ]) : void
Parameters
- $key : string
-
The application key.
- $context : string|null = null
-
The context to set the key for. If null, uses active context.
setBaseUrl()
Set the base URL for API requests.
public
static setBaseUrl(string $url[, string|null $context = null ]) : void
Parameters
- $url : string
-
The base URL.
- $context : string|null = null
-
The context to set the URL for. If null, uses active context.
Tags
setContext()
Set the active context for configuration.
public
static setContext(string $context) : void
Parameters
- $context : string
-
The context name to make active.
setTimeout()
Set the timeout for API requests.
public
static setTimeout(int $timeout[, string|null $context = null ]) : void
Parameters
- $timeout : int
-
The timeout in seconds.
- $context : string|null = null
-
The context to set the timeout for. If null, uses active context.
validate()
Validate the configuration for a specific context.
public
static validate([string|null $context = null ]) : void
Parameters
- $context : string|null = null
-
The context to validate. If null, uses active context.
Tags
syncLegacyValues()
Synchronize legacy static properties with active context values.
private
static syncLegacyValues() : void
This ensures backward compatibility when switching contexts.