-
-
Notifications
You must be signed in to change notification settings - Fork 0
ConfigContainer
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
| Constant | Visibility | Type | Value |
|---|---|---|---|
ALIAS |
public | string | 'config' |
Constructs a new ConfigContainer instance.
public __construct(\FastForward\Config\ConfigInterface $config): mixedThis 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 |
Determines whether the container can return an entry for the given identifier.
public has(string $id): boolThis 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
Retrieves an entry of the container by its identifier.
public get(string $id): mixedThis 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