Skip to content

ConfigContainer

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

Class ConfigContainer.

Provides a PSR-11 compatible container interface for accessing configuration values.

This container implementation SHALL resolve configuration keys by prefix using the alias "config". For example, a request for "config.db.host" will attempt to fetch the key "db.host" from the underlying ConfigInterface.

Identifiers such as 'config', ConfigInterface::class, and the concrete config class MUST return the configuration instance itself. Requests for unknown or invalid identifiers MUST result in a ContainerNotFoundException.


  • Full name: \FastForward\Config\Container\ConfigContainer
  • This class is marked as final and can't be subclassed
  • This class implements: ContainerInterface
  • This class is a Final class

Constants

Constant Visibility Type Value
ALIAS public string 'config'

Methods

__construct

Constructs a new ConfigContainer instance.

public __construct(\FastForward\Config\ConfigInterface $config): mixed

This constructor SHALL wrap an existing ConfigInterface instance and expose it through PSR-11 get() and has() methods with namespace-style key resolution.

Parameters:

Parameter Type Description
$config \FastForward\Config\ConfigInterface the configuration instance to expose as a container

has

Determines whether the container can return an entry for the given identifier.

public has(string $id): bool

This method SHALL return true if:

  • The identifier matches known internal bindings (alias, interface, or class).
  • The identifier is prefixed with 'config' and corresponds to an existing key in the configuration.

Parameters:

Parameter Type Description
$id string identifier of the entry to look for

Return Value:

true if the entry can be resolved; false otherwise


get

Retrieves an entry of the container by its identifier.

public get(string $id): mixed

This method SHALL resolve identifiers in the following order:

  • If the identifier matches 'config', ConfigInterface::class, or the concrete config class, it SHALL return the ConfigInterface instance itself.
  • If the identifier is prefixed with 'config.', the suffix SHALL be used to query the configuration. If the configuration key exists, its value SHALL be returned.
  • If the identifier cannot be resolved, a ContainerNotFoundException MUST be thrown.

Parameters:

Parameter Type Description
$id string identifier of the entry to retrieve

Return Value:

the value associated with the identifier

Throws:

if the identifier cannot be resolved


Clone this wiki locally