public function getValue(string $key, string $file = null)
    {
        $nbConfigFile = count($this->config);

        if ($file === null && $nbConfigFile > 1) {
            throw new Exception(
                'There are many config files. Please indicate the file to'
                .' obtain the config '.$key,
                $this::ERR_GETVALUE_FILE_NOT_INDICATED
            );
        }

        if ($nbConfigFile === 1) {
            $file = key($this->config);
        }

        if (!isset($this->config[$file])) {
            throw new Exception(
                'The file '.$file.' has not been found for config '.$key,
                $this::ERR_FILE_NOT_FOUND
            );
        }

        $config = (array) $this->config[$file];
        if (!array_key_exists($key, $config)) {
            throw new Exception(
                'The config key '.$key.' has not been found',
                $this::ERR_KEY_NOT_FOUND
            );
        }

        return $config[$key];
    }
public function getValue(string $key, string $file = null)
    {
        $nbConfigFile = count($this->config);

        if ($file === null && $nbConfigFile > 1) {
            throw new Exception(
                'There are many config files. Please indicate the file to'
                .' obtain the config '.$key,
                $this::ERR_GETVALUE_FILE_NOT_INDICATED
            );
        }

        if ($nbConfigFile === 1) {
            $file = key($this->config);
        }

        if (!isset($this->config[$file])) {
            throw new Exception(
                'The file '.$file.' has not been found for config '.$key,
                $this::ERR_FILE_NOT_FOUND
            );
        }

        $config = (array) $this->config[$file];
        if (!array_key_exists($key, $config)) {
            throw new Exception(
                'The config key '.$key.' has not been found',
                $this::ERR_KEY_NOT_FOUND
            );
        }

        return $config[$key];
    }
public function getValue ( string $ key , string $ file = null ) { $ nbConfigFile = count ( $ this -> config ) ; if ( $ file === null && $ nbConfigFile > 1 ) { throw new Exception ( 'There are many config files. Please indicate the file to' . ' obtain the config ' . $ key , $ this :: ERR_GETVALUE_FILE_NOT_INDICATED ) ; } if ( $ nbConfigFile === 1 ) { $ file = key ( $ this -> config ) ; } if ( ! isset ( $ this -> config [ $ file ] ) ) { throw new Exception ( 'The file ' . $ file . ' has not been found for config ' . $ key , $ this :: ERR_FILE_NOT_FOUND ) ; } $ config = ( array ) $ this -> config [ $ file ] ; if ( ! array_key_exists ( $ key , $ config ) ) { throw new Exception ( 'The config key ' . $ key . ' has not been found' , $ this :: ERR_KEY_NOT_FOUND ) ; } return $ config [ $ key ] ; }
Return a config value for a key

@param string $key The asked key for the value
@param string $file (default null) If many file is loaded, the file name
where is the key. Is the file is into a sub-directory, the
sub-directory should be present.

@return mixed

@throws \Exception If file parameter is null and there are many files. Or
if the file not exist. Or if the key not exist.
Return a config value for a key