Skip to content

ConfigInterface

github-actions edited this page Mar 27, 2026 · 1 revision

Interface ConfigInterface.

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]]].


  • Full name: \FastForward\Config\ConfigInterface
  • Parent interfaces: IteratorAggregate, ArrayAccess

Methods

has

Determines if the specified key exists in the configuration.

public has(string $key): bool

Dot notation MAY be used to check nested keys.

Parameters:

Parameter Type Description
$key string the configuration key to check

Return Value:

TRUE if the key exists, FALSE otherwise


get

Retrieves a value from the configuration by key.

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

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:

Parameter Type Description
$key string the configuration key to retrieve
$default mixed the default value if the key is not present

Return Value:

the value associated with the key or the default


set

Sets a configuration value or merges an array or ConfigInterface.

public set(array|self|string $key, mixed|null $value = null): void

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:

Parameter Type Description
$key array|self|string a configuration key, an array, or another ConfigInterface
$value mixed|null the value to assign, if a key is provided

remove

Removes a configuration key and its associated value.

public remove(string $key): void

Dot notation MAY be used to specify nested keys. If the key does not exist, this method MUST do nothing.

Parameters:

Parameter Type Description
$key string the configuration key to remove

toArray

Exports the configuration as a nested associative array.

public toArray(): array

Implementations MUST return a deep array representation of all configuration data.

Return Value:

the full configuration array


Clone this wiki locally