From 727391aa8f277f9fc5cb94434d52b2fcaa436059 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sat, 23 Oct 2021 12:59:39 +0200 Subject: [PATCH] Added default value to the config helper --- application/helpers/config_helper.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/application/helpers/config_helper.php b/application/helpers/config_helper.php index c612df00..49df8463 100644 --- a/application/helpers/config_helper.php +++ b/application/helpers/config_helper.php @@ -15,12 +15,15 @@ * Quickly fetch the value of a framework configuration. * * @param string $key Configuration key. + * @param mixed $default Default value in case the requested config has no value. * * @return mixed Returns the configuration value. */ -function config($key) +function config($key, $default = NULL) { $CI = &get_instance(); - return $CI->config->item($key); + $value = $CI->config->item($key); + + return $value ?? $default; }