ConfigInterface
Interface ConfigInterface.
Description
Defines the contract for configuration storage and access. Implementing classes MUST support key-based configuration retrieval, nested data export, and mutation in a standardized format.
This interface SHALL extend the IteratorAggregate interface to allow iteration.
Keys MAY use dot notation to access nested structures, e.g., my.next.key
corresponds to ['my' => ['next' => ['key' => $value]]].
Methods
Retrieves a value from the configuration by key.
Determines if the specified key exists in the configuration.
Removes a configuration key and its associated value.
Sets a configuration value or merges an array or ConfigInterface.
Exports the configuration as a nested associative array.
Retrieves a value from the configuration by key.
public
get(
string
$key[,
mixed
$default = null]) : mixed
Description
Dot notation MAY be used to access nested keys. If the key does not exist, the provided default value MUST be returned. Implementations MAY return complex nested structures or objects.
Parameters
$key
:
string
Description
the configuration key to retrieve
$default
:
mixed
=
null
Description
the default value if the key is not present
Return values
Description
the value associated with the key or the default
Determines if the specified key exists in the configuration.
public
has(
string
$key) : bool
Description
Dot notation MAY be used to check nested keys.
Parameters
$key
:
string
Description
the configuration key to check
Return values
Description
TRUE if the key exists, FALSE otherwise
Removes a configuration key and its associated value.
public
remove(
string
$key) : void
Description
Dot notation MAY be used to specify nested keys. If the key does not exist, this method MUST do nothing.
Parameters
$key
:
string
Description
the configuration key to remove
Sets a configuration value or merges an array or ConfigInterface.
public
set(
array<string|int, mixed>|self|string
$key[,
mixed|null
$value = null]) : void
Description
Dot notation MAY be used to set values into nested structures. The method MUST support:
- Setting a single key/value pair.
- Merging an entire associative array.
- Merging another ConfigInterface instance.
Parameters
$key
:
array<string|int, mixed>|self|string
Description
a configuration key, an array, or another ConfigInterface
$value
:
mixed|null
=
null
Description
the value to assign, if a key is provided
Exports the configuration as a nested associative array.
public
toArray() : array<string|int, mixed>
Description
Implementations MUST return a deep array representation of all configuration data.
Return values
Description
the full configuration array