Skip to content

ArrayConfig

github-actions edited this page Mar 27, 2026 · 2 revisions

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

Methods

__construct

Constructs the ArrayConfig instance.

public __construct(array $config = []): mixed

This constructor SHALL initialize the internal configuration store using normalized keys.

Parameters:

Parameter Type Description
$config array an optional initial configuration array

has

Determines whether the given configuration key exists.

public has(string $key): bool

Parameters:

Parameter Type Description
$key string the dot-notation configuration key to check

Return Value:

TRUE if the key exists, FALSE otherwise


get

Retrieves a value from the configuration.

public get(string $key, mixed $default = null): mixed|self

If 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


set

Sets configuration values into the internal data store.

public set(array|\FastForward\Config\ConfigInterface|string $key, mixed|null $value = null): void

If 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


remove

Removes a configuration key and its associated value.

public remove(string $key): void

If the key does not exist, this method SHALL do nothing.

Parameters:

Parameter Type Description
$key string the configuration key to remove

getIterator

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


toArray

Converts the entire configuration to an associative array.

public toArray(): array

This method MUST export the configuration in its current state.

Return Value:

the exported configuration array


Clone this wiki locally