diff options
Diffstat (limited to 'lib/Minz/User.php')
| -rw-r--r-- | lib/Minz/User.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/Minz/User.php b/lib/Minz/User.php new file mode 100644 index 000000000..252584e83 --- /dev/null +++ b/lib/Minz/User.php @@ -0,0 +1,27 @@ +<?php + +/** + * The Minz_User class handles the user information. + */ +final class Minz_User { + + public const INTERNAL_USER = '_'; + + public const CURRENT_USER = 'currentUser'; + + /** + * @return string the name of the current user, or null if there is none + */ + public static function name(): ?string { + $currentUser = trim(Minz_Session::param(Minz_User::CURRENT_USER, '')); + return $currentUser === '' ? null : $currentUser; + } + + /** + * @param string $name the name of the new user. Set to empty string to clear the user. + */ + public static function change(string $name = ''): void { + $name = trim($name); + Minz_Session::_param(Minz_User::CURRENT_USER, $name === '' ? false : $name); + } +} |
