-
-
Notifications
You must be signed in to change notification settings - Fork 0
ConfigHelper
Class ConfigHelper.
Provides a set of static helper methods for manipulating configuration arrays, particularly handling associative arrays with dot notation and nested structures. This class SHALL NOT be instantiated and MUST be used statically.
- Full name:
\FastForward\Config\Helper\ConfigHelper - This class is marked as final and can't be subclassed
- This class is a Final class
Determines if the provided value is an associative array.
public static isAssoc(mixed $value): boolThis method SHALL check whether the given array uses string keys, distinguishing it from indexed arrays.
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$value |
mixed | the value to check |
Return Value:
true if the array is associative; false otherwise
Normalizes a configuration array using dot notation delimiters.
public static normalize(array $config): arrayThis method SHALL recursively convert keys containing delimiters into nested arrays. For example, a key like "database.host" SHALL be transformed into ['database' => ['host' => 'value']].
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$config |
array | the configuration array to normalize |
Return Value:
the normalized configuration array
Flattens a nested configuration array into a dot-notated traversable set.
public static flatten(array $config, string $rootKey = ''): \Traversable<string,mixed>This method SHALL recursively iterate through the nested array structure and convert it into a flat representation where keys reflect the nested path. A value like ['database' => ['host' => 'localhost']] SHALL be transformed into ['database.host' => 'localhost'].
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$config |
array | the configuration array to flatten |
$rootKey |
string | (Optional) The root key prefix for recursive calls |
Return Value:
a traversable list of flattened key-value pairs