-
-
Notifications
You must be signed in to change notification settings - Fork 0
ArrayConfig
Class ArrayConfig.
Provides a configuration management system with dot notation access. This class SHALL encapsulate configuration data using the DotAccessData library. It MUST support nested keys and provide export, iteration, and dynamic update capabilities.
- Full name:
\FastForward\Config\ArrayConfig - This class is marked as final and can't be subclassed
- This class implements:
\FastForward\Config\ConfigInterface - This class is a Final class
Constructs the ArrayConfig instance.
public __construct(array $config = []): mixedThis constructor SHALL initialize the internal configuration store using normalized keys.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$config |
array | an optional initial configuration array |
Determines whether the given configuration key exists.
public has(string $key): boolParameters:
| Parameter | Type | Description |
|---|---|---|
$key |
string | the dot-notation configuration key to check |
Return Value:
TRUE if the key exists, FALSE otherwise
Retrieves a value from the configuration.
public get(string $key, mixed $default = null): mixed|selfIf the value is a nested associative array, a new instance of ArrayConfig SHALL be returned. If the key is not found and no default is provided, a MissingPathException SHOULD be thrown.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key |
string | the configuration key to retrieve |
$default |
mixed | the default value to return if the key does not exist |
Return Value:
the configuration value, or a nested ArrayConfig instance
Sets configuration values into the internal data store.
public set(array|\FastForward\Config\ConfigInterface|string $key, mixed|null $value = null): voidIf a value is provided, the key MUST be a string. If the input is an associative array or another ConfigInterface instance, it SHALL be normalized before insertion.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key |
array|\FastForward\Config\ConfigInterface|string | the configuration key(s) or configuration object |
$value |
mixed|null | the value to assign to the specified key, if applicable |
Throws:
if the key is not a string when a value is provided
Removes a configuration key and its associated value.
public remove(string $key): voidIf the key does not exist, this method SHALL do nothing.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key |
string | the configuration key to remove |
Retrieves a traversable set of flattened configuration data.
public getIterator(): \Traversable<string,mixed>This method SHALL return an iterator where each key represents the nested path in dot notation, and each value is the corresponding value. For example ['database' => ['host' => 'localhost']] becomes ['database.host' => 'localhost'].
Return Value:
an iterator of flattened key-value pairs
Converts the entire configuration to an associative array.
public toArray(): arrayThis method MUST export the configuration in its current state.
Return Value:
the exported configuration array