@param string $file
@param int    $env

@throws \InvalidArgumentException
@throws \UnexpectedValueException
557246
public function loadConfig($file, $env = self::ENV_COMMON)
    {
        $this->loadConfigFile($file, $env, false);
    }
402189
public function addResource(string $file): void
    {
        $contents = file_get_contents($file);
        
        if ($contents === false) {
            throw new \RuntimeException("Error reading file at $file.");
        }
        
        $this->processData(json_decode($contents, true));
    }
1247303
public function add($file)
    {
        // Need to convert DirectorIterators to SplFileInfo objects as it
        // appears ArrayCollection can't distinguish between them.
        if ($file instanceof DirectoryIterator &&
            ! $file->isDir() &&
            ! $file->isDot() &&
            ! $file->getFilename() != '..'
        ) {
            $file = new \SplFileInfo($file->getPathname());
        }

        $fileInfo = $file instanceof File
            ? $file->getInfo()
            : $file
        ;

        if ($fileInfo instanceof SplFileInfo) {
            if (false === $fileInfo->isDir()
                && false === $this->files->contains($file)
            ) {
                $this->files->add($file);
            }
            return true;
        }
        elseif (
            ($isArray = is_array($file)) ||
            $file instanceof Traversable
        ) {
            foreach ($file as $key => $f) {
                try {
                    $this->add($f);
                }
                catch (InvalidArgumentException $e) {
                    throw new UnexpectedValueException(
                        sprintf(
                            "%s's value at %s caused InvalidArgumentException",
                            is_numeric($key) ? 'index '.$key : "key '{$key}'",
                            $isArray ? 'Array' : 'FileBag',
                            $key
                        ),
                        null,
                        $e
                    );
                }
                catch (UnexpectedValueException $e) {
                    throw new UnexpectedValueException(
                        sprintf(
                            "%s's value at %s caused UnexpectedValueException",
                            is_numeric($key) ? 'index '.$key : "key '{$key}'",
                            $isArray ? 'Array' : 'FileBag',
                            $key
                        ),
                        null,
                        $e
                    );
                }
            }
            return true;
        }

        throw InvalidArgumentException::create(
            implode('|', array(
                'Axstrad\Component\Filesystem\FileBag',
                'SplFileInfo[]',
                'Axstrad\Component\Filesystem\File[]',
                'SplFileInfo',
                'Axstrad\Component\Filesystem\File'
            )),
            $file
        );
    }
115585
public function setEnv($properties)
    {
        $envPath = app()->environmentFilePath();

        $contents = File::get($envPath);
        if(!$contents) {
            throw new \Exception('Could not read env file');
        }

        foreach($properties as $key => $value){
            // Env value must be set so the already loaded file reflect changes
            $this->setEnvValue($key, $value);

            // Change content
            $contents = preg_replace('/' . $key . '=(.*)/', $key . '=' . $value, $contents);
        }

        if (File::put($envPath, $contents) === false) {
            throw new \Exception('Could not write env file');
        }

        return true;
    }
535282
protected function load(string $file): void
	{
		$this->configuration[$file] = $this->loader->load($file, $this->environment);
	}
1089510
public static function setFile($file)
    {
        if (is_file($file)) {
            $options = Yaml::parse(file_get_contents($file));
            self::$instance = new self($options);
            self::$instance->validateOptions();
        } else {
            throw new Exception("Can't find config file at ".$file);
        }
    }
133057
public function load($path, $file = '.env')
    {
        try {
            $env = new \Dotenv\Dotenv($path, $file);
            $env->load();

            return true;
        } catch (\Dotenv\Exception\InvalidPathException $e) {
            return false;
        }
    }
755531
public function loadConfigFile($file, $env = null)
    {
        $file = str_replace('%env%', $env ?: $this->name, $file);
        $config = $this->getFileConfig($file);
        if ($config) {
            $this->wei->setConfig($config);
        }
        return $this;
    }
885322
protected function loadFile($file)
    {
        $requiredFiles = $this->getRequiredFiles($file);
        $this->values[$file] = true;

        foreach ($requiredFiles as $fileToRequire) {
            $overrideConfig = require $fileToRequire['path'];
            $this->config->addConfig([$file => $overrideConfig], $fileToRequire['environment']);
        }
    }
1224390
public static function overload($envFile = ".env")
    {
        self::getLoader()->overloader = true;
        self::getLoader()->innerLoad($envFile);
    }
29980
public function setFile($file)
    {
        if (!is_file($file)) {
            throw new \InvalidArgumentException('File not found: '.$file, ErrorCodes::FILE_NOT_FOUND);
        }
        if (!is_readable($file)) {
            throw new \InvalidArgumentException('File is not readable: '.$file, ErrorCodes::FILE_NOT_READABLE);
        }
        $this->file = $file;
        return $this;
    }
546731
public function withFile($file)
    {
        if (!is_file($file)) {
            throw new \InvalidArgumentException('File: ' . $file . ' not exists.');
        }

        return $this->withFileStream(new Stream($file));
    }
1090587
public static function fromFile(string $file, string $locale): Resource
    {
        if (!is_file($file)) {
            throw new \InvalidArgumentException("$file is not a file");
        }
        
        $contents = file_get_contents($file);
        
        if ($contents === false) {
            throw new \RuntimeException("Error reading file at $file.");
        }
        
        return static::fromString($contents, $locale);
    }
599400
public static function setDriver($driver, $env = null)
    {
        $file = realpath(dirname(__FILE__)."/../drivers/$driver.php");
        if (!file_exists($file)) {
            Log::log("ERROR: Driver file $file does not exists");
            return null;
        }
        self::$_driver[self::selectEnvironment($env)] = $driver;
        include_once $file;
    }
1225410
protected function setEnvironmentFilePath($app, $file)
    {
        if (file_exists($app->environmentPath() . '/' . $file)) {
            $app->loadEnvironmentFrom($file);
        }
    }
518093
protected function parseMainFile(string $file): MutableBag
    {
        $envs = $this->parse($file);

        if (!$envs->has('default')) {
            $envs['default'] = new MutableBag();
        }

        $envs = $this->sortEnvs($envs);

        // Merge in parent configs for each environment, specified with "_extends" key
        foreach ($envs as $name => $config) {
            // Skip "default" since this is the based for all
            if ($name === 'default') {
                continue;
            }

            $parent = $config->remove('_extends', 'default');
            $envs[$name] = $envs[$parent]->replaceRecursive($config);
        }

        return $envs;
    }
280039
protected function addResourceFile(string $file): void
    {
        if (!is_file($file)) {
            throw new \InvalidArgumentException("$file is not a file");
        }
        
        $contents = file_get_contents($file);
        
        if ($contents === false) {
            throw new \RuntimeException("Error reading file at $file.");
        }
        
        $this->addResourceString($contents);
    }