Make Config::get() case insensitive

This commit is contained in:
Dale Davies
2023-04-14 11:44:05 +01:00
parent 44bf706c31
commit c01bc0d815

View File

@@ -111,11 +111,12 @@ class Config {
* Retrieves the config parameter provided in $key, first checks for its
* existence.
*
* @param string $key The requested config parameter key.
* @param string $key The requested config parameter key, not case sensitive.
* @param bool $strict Throw exception if requested param is not found, or return null.
* @return mixed The selected value from the configuration array.
*/
public function get(string $key, $strict = true): mixed {
$key = strtolower($key);
if (!$this->config->has($key) && $strict === true) {
throw new ConfigException('Config key does not exist... ('.$key.')');
}