diff options
author | Joas Schilling <coding@schilljs.com> | 2019-02-06 19:07:20 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-02-22 10:25:41 +0300 |
commit | a11ef5134cb4200399e74811bbf9d1100923efcd (patch) | |
tree | 413ab27f1f4afe390377a858d01e2e9b189731f9 /lib | |
parent | e7f0e8ba03363f37631ded3099d4e2bf0df5d5f6 (diff) |
Add methods to get casted system values
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/AllConfig.php | 36 | ||||
-rw-r--r-- | lib/public/IConfig.php | 30 |
2 files changed, 66 insertions, 0 deletions
diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php index 09520aae2a9..05ac1bad64b 100644 --- a/lib/private/AllConfig.php +++ b/lib/private/AllConfig.php @@ -126,6 +126,42 @@ class AllConfig implements \OCP\IConfig { } /** + * Looks up a boolean system wide defined value + * + * @param string $key the key of the value, under which it was saved + * @param mixed $default the default value to be returned if the value isn't set + * @return mixed the value or $default + * @since 16.0.0 + */ + public function getSystemValueBool(string $key, bool $default = false): bool { + return (bool) $this->getSystemValue($key, $default); + } + + /** + * Looks up an integer system wide defined value + * + * @param string $key the key of the value, under which it was saved + * @param mixed $default the default value to be returned if the value isn't set + * @return mixed the value or $default + * @since 16.0.0 + */ + public function getSystemValueInt(string $key, int $default = 0): int { + return (int) $this->getSystemValue($key, $default); + } + + /** + * Looks up a string system wide defined value + * + * @param string $key the key of the value, under which it was saved + * @param mixed $default the default value to be returned if the value isn't set + * @return mixed the value or $default + * @since 16.0.0 + */ + public function getSystemValueString(string $key, string $default = ''): string { + return (string) $this->getSystemValue($key, $default); + } + + /** * Looks up a system wide defined value and filters out sensitive data * * @param string $key the key of the value, under which it was saved diff --git a/lib/public/IConfig.php b/lib/public/IConfig.php index e4cd158f872..878c0acf0c3 100644 --- a/lib/public/IConfig.php +++ b/lib/public/IConfig.php @@ -75,6 +75,36 @@ interface IConfig { public function getSystemValue($key, $default = ''); /** + * Looks up a boolean system wide defined value + * + * @param string $key the key of the value, under which it was saved + * @param bool $default the default value to be returned if the value isn't set + * @return bool the value or $default + * @since 16.0.0 + */ + public function getSystemValueBool(string $key, bool $default = false): bool; + + /** + * Looks up an integer system wide defined value + * + * @param string $key the key of the value, under which it was saved + * @param int $default the default value to be returned if the value isn't set + * @return int the value or $default + * @since 16.0.0 + */ + public function getSystemValueInt(string $key, int $default = 0): int; + + /** + * Looks up a string system wide defined value + * + * @param string $key the key of the value, under which it was saved + * @param string $default the default value to be returned if the value isn't set + * @return string the value or $default + * @since 16.0.0 + */ + public function getSystemValueString(string $key, string $default = ''): string; + + /** * Looks up a system wide defined value and filters out sensitive data * * @param string $key the key of the value, under which it was saved |