public function loadFile($path)
    {
        if (!is_string($path)) {
            throw new InvalidArgumentException(
                'File must be a string'
            );
        }

        if (!file_exists($path)) {
            throw new InvalidArgumentException(
                sprintf('File "%s" does not exist', $path)
            );
        }

        $ext = pathinfo($path, PATHINFO_EXTENSION);
        switch ($ext) {
            case 'php':
                return $this->loadPhpFile($path);

            case 'json':
                return $this->loadJsonFile($path);

            case 'ini':
                return $this->loadIniFile($path);

            case 'yml':
            case 'yaml':
                return $this->loadYamlFile($path);
        }

        $validConfigExts = [ 'ini', 'json', 'php', 'yml' ];
        throw new InvalidArgumentException(sprintf(
            'Unsupported file format for "%s"; must be one of "%s"',
            $path,
            implode('", "', $validConfigExts)
        ));
    }
public function loadFile($path)
    {
        if (!is_string($path)) {
            throw new InvalidArgumentException(
                'File must be a string'
            );
        }

        if (!file_exists($path)) {
            throw new InvalidArgumentException(
                sprintf('File "%s" does not exist', $path)
            );
        }

        $ext = pathinfo($path, PATHINFO_EXTENSION);
        switch ($ext) {
            case 'php':
                return $this->loadPhpFile($path);

            case 'json':
                return $this->loadJsonFile($path);

            case 'ini':
                return $this->loadIniFile($path);

            case 'yml':
            case 'yaml':
                return $this->loadYamlFile($path);
        }

        $validConfigExts = [ 'ini', 'json', 'php', 'yml' ];
        throw new InvalidArgumentException(sprintf(
            'Unsupported file format for "%s"; must be one of "%s"',
            $path,
            implode('", "', $validConfigExts)
        ));
    }
public function loadFile ( $ path ) { if ( ! is_string ( $ path ) ) { throw new InvalidArgumentException ( 'File must be a string' ) ; } if ( ! file_exists ( $ path ) ) { throw new InvalidArgumentException ( sprintf ( 'File "%s" does not exist' , $ path ) ) ; } $ ext = pathinfo ( $ path , PATHINFO_EXTENSION ) ; switch ( $ ext ) { case 'php' : return $ this -> loadPhpFile ( $ path ) ; case 'json' : return $ this -> loadJsonFile ( $ path ) ; case 'ini' : return $ this -> loadIniFile ( $ path ) ; case 'yml' : case 'yaml' : return $ this -> loadYamlFile ( $ path ) ; } $ validConfigExts = [ 'ini' , 'json' , 'php' , 'yml' ] ; throw new InvalidArgumentException ( sprintf ( 'Unsupported file format for "%s"; must be one of "%s"' , $ path , implode ( '", "' , $ validConfigExts ) ) ) ; }
Loads a configuration file.

@param  string $path A path to a supported file.
@throws InvalidArgumentException If the path is invalid.
@return array An array on success.
Loads a configuration file .