Config/ConfigLoader.php
public static function load(string $filename): ConfigInterface
    {
        if (!file_exists($filename)) {
            throw new \RuntimeException(sprintf('Expected config in %s, but the file does not exist.', $filename), 1);
        }
        // Try to determine the realpath of the file, if possible.
        $filename = realpath($filename) ?: $filename;
        try {
            $config = require $filename;
        } catch (Exception $e) {
            throw new \RuntimeException(sprintf('There was an error loading config from %s. Message: %s', $filename, $e->getMessage()), 1, $e);
        }
        if (1 === $config) {
            throw new \RuntimeException(sprintf('No configuration was returned from %s.', $filename), 1);
        }
        if (!$config instanceof ConfigInterface) {
            throw new \RuntimeException(sprintf('Configuration returned from %s is not an instance of %s.', $filename, ConfigInterface::class), 1);
        }
        if ('' === $config->getDocroot()) {
            $config->setDocroot(dirname($filename));
        }
        if ('' === $config->getCachePrefix()) {
            $config->setCachePrefix(md5($filename));
        }

        return $config;
    }
public static function load(string $filename): ConfigInterface
    {
        if (!file_exists($filename)) {
            throw new \RuntimeException(sprintf('Expected config in %s, but the file does not exist.', $filename), 1);
        }
        // Try to determine the realpath of the file, if possible.
        $filename = realpath($filename) ?: $filename;
        try {
            $config = require $filename;
        } catch (Exception $e) {
            throw new \RuntimeException(sprintf('There was an error loading config from %s. Message: %s', $filename, $e->getMessage()), 1, $e);
        }
        if (1 === $config) {
            throw new \RuntimeException(sprintf('No configuration was returned from %s.', $filename), 1);
        }
        if (!$config instanceof ConfigInterface) {
            throw new \RuntimeException(sprintf('Configuration returned from %s is not an instance of %s.', $filename, ConfigInterface::class), 1);
        }
        if ('' === $config->getDocroot()) {
            $config->setDocroot(dirname($filename));
        }
        if ('' === $config->getCachePrefix()) {
            $config->setCachePrefix(md5($filename));
        }

        return $config;
    }
public static function load ( string $ filename ) : ConfigInterface { if ( ! file_exists ( $ filename ) ) { throw new \ RuntimeException ( sprintf ( 'Expected config in %s, but the file does not exist.' , $ filename ) , 1 ) ; } // Try to determine the realpath of the file, if possible. $ filename = realpath ( $ filename ) ? : $ filename ; try { $ config = require $ filename ; } catch ( Exception $ e ) { throw new \ RuntimeException ( sprintf ( 'There was an error loading config from %s. Message: %s' , $ filename , $ e -> getMessage ( ) ) , 1 , $ e ) ; } if ( 1 === $ config ) { throw new \ RuntimeException ( sprintf ( 'No configuration was returned from %s.' , $ filename ) , 1 ) ; } if ( ! $ config instanceof ConfigInterface ) { throw new \ RuntimeException ( sprintf ( 'Configuration returned from %s is not an instance of %s.' , $ filename , ConfigInterface :: class ) , 1 ) ; } if ( '' === $ config -> getDocroot ( ) ) { $ config -> setDocroot ( dirname ( $ filename ) ) ; } if ( '' === $ config -> getCachePrefix ( ) ) { $ config -> setCachePrefix ( md5 ( $ filename ) ) ; } return $ config ; }
Loads a ConfigInterface from a PHP file.

@param string $filename .mannequin.php file.

@return \LastCall\Mannequin\Core\Config\ConfigInterface
Loads a ConfigInterface from a PHP file .