$settings */ public static function create(ConfigLoaderInterface $repository, array $settings): SystemConfiguration { return new SystemConfiguration($repository, self::flatten($settings)); } /** * @param array $settings */ public static function createStub(array $settings = []): SystemConfiguration { return new SystemConfiguration(new TestConfigLoader([]), self::flatten($settings)); } /** * @param array $settings * @return array */ public static function flatten(array $settings): array { $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($settings)); $newConfig = []; foreach ($iterator as $value) { $keys = []; foreach (range(0, $iterator->getDepth()) as $depth) { $keys[] = $iterator->getSubIterator($depth)->key(); } $newConfig[implode('.', $keys)] = $value; } return $newConfig; } }