Skip to content

ConfigHelper

github-actions edited this page Mar 27, 2026 · 2 revisions

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

Methods

isAssoc

Determines if the provided value is an associative array.

public static isAssoc(mixed $value): bool

This 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


normalize

Normalizes a configuration array using dot notation delimiters.

public static normalize(array $config): array

This 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


flatten

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


Clone this wiki locally