allow setting a default value (#6908)

This commit is contained in:
frytimo 2024-03-01 13:26:51 -04:00 committed by GitHub
parent 0626fc1c9a
commit ebe12ef338
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -66,7 +66,7 @@ class settings {
* @param text category
* @param text subcategory
*/
public function get($category = null, $subcategory = null) {
public function get(string $category = null, string $subcategory = null, mixed $default_value = null): mixed {
if (empty($category)) {
return $this->settings;
@ -75,7 +75,7 @@ class settings {
return $this->settings[$category];
}
else {
return $this->settings[$category][$subcategory];
return $this->settings[$category][$subcategory] ?? $default_value;
}
}