public function reload(): void
    {
        $config = [];
        foreach($this->configSources as $src) {
            // If it's a string, then it's a file or directory path
            if (is_string($src)) {
                // If directory, get all config files within it, recursively
                if (is_dir($src)) {
                    $getConfigFiles = function(string $path) use (&$getConfigFiles) {
                        $fragments = [];
                        if (is_dir($path)) {
                            $d = dir($path);
                            while (($f = $d->read()) !== false) {
                                if ($f[0] === '.') {
                                    continue;
                                }
                                if (is_dir("$path/$f")) {
                                    $fragments = array_merge($fragments, $getConfigFiles("$path/$f"));
                                } else {
                                    $fragments[] = "$path/$f";
                                }
                            }
                        }
                        return $fragments;
                    };
                    $fragments = $getConfigFiles($src);
                    sort($fragments);
                    foreach($fragments as $c) {
                        $config = array_replace_recursive($config, $this->parseConfig(file_get_contents($c)));
                    }

                // If it's a file, just merge it's contents over the current config array
                } elseif (is_file($src)) {
                    $config = array_replace_recursive($config, $this->parseConfig(file_get_contents($src)));

                // If it doesn't exist in the filesystem, and it's not optional, throw an exception
                } elseif (array_search($src, $this->optional) === false) {
                    throw (new MissingConfigFileException("Required config file or directory `$src` is missing."))
                        ->setMissingPath($src);
                }

            // If the source is an array, just merge it in
            } elseif (is_array($src)) {
                $config = array_replace_recursive($config, $src);
            }
        }
        $this->config = $config;
    }
public function reload(): void
    {
        $config = [];
        foreach($this->configSources as $src) {
            // If it's a string, then it's a file or directory path
            if (is_string($src)) {
                // If directory, get all config files within it, recursively
                if (is_dir($src)) {
                    $getConfigFiles = function(string $path) use (&$getConfigFiles) {
                        $fragments = [];
                        if (is_dir($path)) {
                            $d = dir($path);
                            while (($f = $d->read()) !== false) {
                                if ($f[0] === '.') {
                                    continue;
                                }
                                if (is_dir("$path/$f")) {
                                    $fragments = array_merge($fragments, $getConfigFiles("$path/$f"));
                                } else {
                                    $fragments[] = "$path/$f";
                                }
                            }
                        }
                        return $fragments;
                    };
                    $fragments = $getConfigFiles($src);
                    sort($fragments);
                    foreach($fragments as $c) {
                        $config = array_replace_recursive($config, $this->parseConfig(file_get_contents($c)));
                    }

                // If it's a file, just merge it's contents over the current config array
                } elseif (is_file($src)) {
                    $config = array_replace_recursive($config, $this->parseConfig(file_get_contents($src)));

                // If it doesn't exist in the filesystem, and it's not optional, throw an exception
                } elseif (array_search($src, $this->optional) === false) {
                    throw (new MissingConfigFileException("Required config file or directory `$src` is missing."))
                        ->setMissingPath($src);
                }

            // If the source is an array, just merge it in
            } elseif (is_array($src)) {
                $config = array_replace_recursive($config, $src);
            }
        }
        $this->config = $config;
    }
public function reload ( ) : void { $ config = [ ] ; foreach ( $ this -> configSources as $ src ) { // If it's a string, then it's a file or directory path if ( is_string ( $ src ) ) { // If directory, get all config files within it, recursively if ( is_dir ( $ src ) ) { $ getConfigFiles = function ( string $ path ) use ( & $ getConfigFiles ) { $ fragments = [ ] ; if ( is_dir ( $ path ) ) { $ d = dir ( $ path ) ; while ( ( $ f = $ d -> read ( ) ) !== false ) { if ( $ f [ 0 ] === '.' ) { continue ; } if ( is_dir ( "$path/$f" ) ) { $ fragments = array_merge ( $ fragments , $ getConfigFiles ( "$path/$f" ) ) ; } else { $ fragments [ ] = "$path/$f" ; } } } return $ fragments ; } ; $ fragments = $ getConfigFiles ( $ src ) ; sort ( $ fragments ) ; foreach ( $ fragments as $ c ) { $ config = array_replace_recursive ( $ config , $ this -> parseConfig ( file_get_contents ( $ c ) ) ) ; } // If it's a file, just merge it's contents over the current config array } elseif ( is_file ( $ src ) ) { $ config = array_replace_recursive ( $ config , $ this -> parseConfig ( file_get_contents ( $ src ) ) ) ; // If it doesn't exist in the filesystem, and it's not optional, throw an exception } elseif ( array_search ( $ src , $ this -> optional ) === false ) { throw ( new MissingConfigFileException ( "Required config file or directory `$src` is missing." ) ) -> setMissingPath ( $ src ) ; } // If the source is an array, just merge it in } elseif ( is_array ( $ src ) ) { $ config = array_replace_recursive ( $ config , $ src ) ; } } $ this -> config = $ config ; }
Reload the config from it's sources (usually done on SIGHUP to load in
configuration changes in files

@return void
Reload the config from it s sources ( usually done on SIGHUP to load in configuration changes in files