-
-
Notifications
You must be signed in to change notification settings - Fork 0
LazyLoadConfigTrait
Trait LazyLoadConfigTrait.
Implements lazy-loading behavior for configuration access. This trait MUST be used in classes implementing ConfigInterface to defer configuration instantiation until first usage. It SHALL invoke the implementing class as a callable to obtain the actual config instance.
- Full name:
\FastForward\Config\LazyLoadConfigTrait
Implementing class MUST define the __invoke() method to return a ConfigInterface instance.
public __invoke(): \FastForward\Config\ConfigInterface- This method is abstract. Return Value:
the actual configuration instance
Retrieves a configuration value by key.
public get(string $key, mixed|null $default = null): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$key |
string | the configuration key to retrieve |
$default |
mixed|null | the default value if the key is not found |
Return Value:
the value of the configuration key or the default
Checks for existence of a configuration key.
public has(string $key): boolParameters:
| Parameter | Type | Description |
|---|---|---|
$key |
string | the configuration key to check |
Return Value:
TRUE if the key exists, FALSE otherwise
Sets configuration data.
public set(array|\FastForward\Config\ConfigInterface|string $key, mixed|null $value = null): voidParameters:
| Parameter | Type | Description |
|---|---|---|
$key |
array|\FastForward\Config\ConfigInterface|string | the key or set of keys/values to set |
$value |
mixed|null | the value to set if a single key is provided |
Removes a configuration key.
public remove(string $key): voidParameters:
| Parameter | Type | Description |
|---|---|---|
$key |
string | the configuration key to remove |
Exports the entire configuration to an array.
public toArray(): arrayReturn Value:
the configuration as an associative array
Retrieves an iterator for traversing the configuration data.
public getIterator(): \TraversableReturn Value:
an iterator over the configuration