Load & Merge Configuration file to existing config

@param      string     $filename

@throws     Exception  On invalid JSON file

@return     self
968754
public function loadAndMerge(string $filename)
  {
    # Attempt to load config file
    if ( \file_exists($filename) ) {
      # Set filename
      $this->filename = $filename;
      # Load the config
      $configArray = \json_decode( \file_get_contents($filename), true);
      if ($configArray) {
        // $configArray = $this->array_change_key_case_recursive($configArray); // Lowercase the keys
        # Merge the Config with existing config
        $this->confValues = \array_replace_recursive($this->confValues, $configArray);

      } else {
        throw new SpinException('Invalid JSON file "'.$filename.'"');

      }

    }

    return $this;
  }
236689
public function merge(File $other): self
    {
        $new = new static($this->filename);
        $new->issues = array_merge($this->issues, $other->issues);
        return $new;
    }
513467
protected function loadFile($filename)
    {
        if (!is_string($filename)) {
            throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be string, %s given', __METHOD__, gettype($filename)));
        }

        try {
            $content = file_get_contents($filename);
        } catch (\Exception $exception) {
            throw new RuntimeException(sprintf('Could not load file %s', $filename));
        }

        if ($content === false) {
            throw new RuntimeException(sprintf('Could not load file %s', $filename));
        }

        return $content;
    }
936352
static public function fromFile(string $filename)
    {
        $yaml = filter_var($filename, FILTER_VALIDATE_URL)
            ? yaml_parse_url($filename)
            : yaml_parse_file($filename);

        YamlException::importFromFile($yaml);
        return $yaml;
    }
439244
public function load($filename)
    {
        if (!file_exists($filename)) {
            throw new \Exception('Ini file "' . $filename . '" doesn\'t exist.');
            return false;
        }
        $this->filename = $filename;
        return $this;
    }
546733
public function fromFile($filename)
    {
        $xml = $this->createDomDocument();
        $xml->load($filename);

        return new Document($xml);
    }
1223650
public function load($filename = null)
    {
        if ($filename === null) {
            $filename = $this->filename;
        }
        if ($filename === null) {
            throw new \LogicException('Can`t load template: property \'filename\' not set.');
        }
        if ( ! file_exists($filename)) {
            throw new \LogicException("file '$filename' does not exists.");
        }
        $this->filename = $filename;

        return $this;
    }
1189387
public function load($filename)
    {
        $json = file_get_contents($filename);
        if (false === $json) {
            // @codeCoverageIgnoreStart
            throw new \RuntimeException("Unable to load file {$filename}");
            // @codeCoverageIgnoreEnd
        }

        $data = Utils::jsonDecode($json, true);
        if (is_array($data)) {
            foreach (Utils::jsonDecode($json, true) as $cookie) {
                $this->setCookie(new SetCookie($cookie));
            }
        } elseif (strlen($data)) {
            throw new \RuntimeException("Invalid cookie file: {$filename}");
        }
    }
1242833
public static function restore(string $fileName = self::FILENAME_CONFIG_DEFAULT): ApiContext
    {
        $contextJsonString = self::getContextJsonString($fileName);

        return static::fromJson($contextJsonString);
    }
903058
public function loadConfig(string $file): self
    {
        if (file_exists($file) === false) {
            throw new \RuntimeException('No such config file.');
        }
        $data = json_decode(file_get_contents($file), true);
        if ($data === null) {
            throw new \RuntimeException('Invalid config file.');
        }
        return $this->setConfigs($data);
    }
645945
protected function loadJsonConfigFile(string $fileKey, string $filePath)
    {
        $json   = file_get_contents($filePath);
        $config = json_decode($json);

        if ($config === null) {
            throw new Exception(
                json_last_error_msg(),
                $this::ERR_JSON_PARSE
            );
        }

        $this->config[$fileKey] = $config;
    }
278916
public function setLocalFile(string $filename): void
    {
        if (empty($filename)) {
            throw new Exception('the filename can not be empty', Exception::LOCAL_FILE_MISSING);
        }

        $this->localFile = $filename;
        $this->loader    = null;
    }
478500
public static function fromFile($filename)
	{
		$filename = realpath($filename);
		if ($filename === false)
			throw new ClientConfigurationException('Configuration file ' . $filename . ' does not exists');

		return static::fromArray(include $filename);
	}
307470
def load(self, filename):
        """"""
        content = open(filename)
        return Config(json.load(content))
1240634
public static function import($fileName, $config=[])
	{
		$config = ArrayHelper::merge(['mode' => 'import', 'fileName' => $fileName, 'asArray' => true], $config);
		return self::widget($config);
	}
871344
public static function loadConfig($filename)
    {
        self::fireEvent('Atomik::Loadconfig::Before', array(&$filename));
        
        // config file format
        if (!preg_match('/.+\.(php|ini|json)$/', $filename)) {
            $found = false;
            foreach (array('php', 'ini', 'json') as $format) {
                if (file_exists("$filename.$format")) {
                    $found = true;
                    break;
                }
            }
            if (!$found) {
                throw new AtomikException("Configuration file '$filename' not found");
            }
            $filename .= ".$format";
        } else {
            $format = substr($filename, strrpos($filename, '.') + 1);
        }
        
        $config = array();
        if ($format === 'ini') {
            if (($data = parse_ini_file($filename, true)) === false) {
                throw new AtomikException('INI configuration malformed');
            }
            $config = self::dimensionizeArray($data, '.');
        } else if ($format === 'json') {
            if (($config = json_decode(file_get_contents($filename), true)) === null) {
                throw new AtomikException('JSON configuration malformed');
            }
        } else {
            if (is_array($return = include($filename))) {
                $config = $return;
            }
        }
        
        self::fireEvent('Atomik::Loadconfig::After', array($filename, &$config));
        return $config;
    }
240043
protected function updateFile($filename)
    {
        $current = Context::getParam('current-version');
        $next = Context::getParam('new-version');

        $content = file_get_contents($filename);
        if (false === strpos($content, $current)) {
            throw new Exception('The version class ' . $filename . " does not contain the current version $current");
        }
        if (isset($this->options['pattern'])) {
            $current = str_replace('%version%', $current, $this->options['pattern']);
            $next = str_replace('%version%', $next, $this->options['pattern']);
        }
        $content = str_replace($current, $next, $content);
        if (false === strpos($content, $next)) {
            throw new Exception('The version class ' . $filename . " could not be updated with version $next");
        }
        file_put_contents($filename, $content);
    }