public function set($key, $value, $type)
{
if ('[' === $key[0]) {
throw new \InvalidArgumentException(sprintf('Invalid configuration, cannot set nested configuration-key "%s". ' . 'Store the top config instead like: key => [sub_key => value].', $key));
}
if ($type !== self::CONFIG_LOCAL && $type !== self::CONFIG_SYSTEM) {
throw new \InvalidArgumentException(sprintf('Config slot "%s" is not valid for setting "%s", use either: ' . 'Config::CONFIG_SYSTEM or Config::CONFIG_LOCAL. ' . 'Note that configuration is always merged back to Config::CONFIG_ALL', $type, $key));
}
if (!is_scalar($value) && !is_array($value)) {
throw new \InvalidArgumentException(sprintf('Configuration can only a be scalar or an array, "%s" type given instead for "%s".', gettype($value), $key));
}
if (in_array($key, self::$protectedConfig, true)) {
throw new \InvalidArgumentException(sprintf('Configuration key "%s" is protected and cannot be overwritten.', $key));
}
$this->config[$type][$key] = $value;
$this->config[self::CONFIG_ALL][$key] = $value;
return $this;
}