[CORE][Util][Common] Correct behaviour for absense of value

This commit is contained in:
Diogo Peralta Cordeiro 2021-10-18 12:29:52 +01:00
parent 517ed953f2
commit 071b769997
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0

View File

@ -73,13 +73,22 @@ abstract class Common
/** /**
* Access sysadmin's configuration preferences for GNU social * Access sysadmin's configuration preferences for GNU social
* Returns value if exists, null if not set
*/ */
public static function config(string $section, ?string $setting = null) public static function config(string $section, ?string $setting = null)
{ {
if (!array_key_exists($section, self::$config)) {
return null;
} else {
if ($setting !== null) { if ($setting !== null) {
if (array_key_exists($setting, self::$config[$section])) {
return self::$config[$section][$setting]; return self::$config[$section][$setting];
} else { } else {
return self::$config[$section] ?? []; return null;
}
} else {
return self::$config[$section];
}
} }
} }