X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Fuser%2Fguest%2Fclass_Guest.php;h=0ffd9eaea0728309fede32fa46ee74ccde5b6521;hb=HEAD;hp=1b6fe579a5cf627a9ac8529cc41dd6abb9414858;hpb=d8a47744662a4850c136828b27341cce16745442;p=core.git diff --git a/framework/main/classes/user/guest/class_Guest.php b/framework/main/classes/user/guest/class_Guest.php index 1b6fe579..0ffd9eae 100644 --- a/framework/main/classes/user/guest/class_Guest.php +++ b/framework/main/classes/user/guest/class_Guest.php @@ -1,18 +1,24 @@ * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.shipsimu.org * @@ -41,7 +47,7 @@ class Guest extends BaseUser implements ManageableGuest, Registerable { * * @return void */ - protected function __construct () { + private function __construct () { // Call parent constructor parent::__construct(__CLASS__); } @@ -82,7 +88,13 @@ class Guest extends BaseUser implements ManageableGuest, Registerable { * @throws UsernameMissingException If the username does not exist * @throws UserNoGuestException If the user is no guest account */ - public static final function createGuestByUsername ($userName) { + public static final function createGuestByUsername (string $userName) { + // Check parameter + if (empty($userName)) { + // Throw IAE + throw new InvalidArgumentException('Paramter "userName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); + } + // Get a new instance $userInstance = new Guest(); @@ -90,10 +102,10 @@ class Guest extends BaseUser implements ManageableGuest, Registerable { $userInstance->setUserName($userName); // Check if username exists - if ($userInstance->ifUsernameExists() === FALSE) { + if ($userInstance->ifUsernameExists() === false) { // Throw an exception here throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); - } elseif ($userInstance->isGuest() === FALSE) { + } elseif ($userInstance->isGuest() === false) { // Sanity check on 'guest' status failed throw new UserNoGuestException(array($userInstance, $userName), self::EXCEPTION_USER_NOT_GUEST_STATUS); } @@ -109,7 +121,13 @@ class Guest extends BaseUser implements ManageableGuest, Registerable { * @param $email Email address of the user * @return $userInstance An instance of this user class */ - public static final function createGuestByEmail ($email) { + public static final function createGuestByEmail (string $email) { + // Check parameter + if (empty($email)) { + // Throw IAE + throw new InvalidArgumentException('Paramter "email" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); + } + // Get a new instance $userInstance = new Guest(); @@ -122,8 +140,7 @@ class Guest extends BaseUser implements ManageableGuest, Registerable { /** * Updates the last activity timestamp and last performed action in the - * database result. You should call flushPendingUpdates() to flush these updates - * to the database layer. + * database result. * * @param $requestInstance A requestable class instance * @return void @@ -132,13 +149,4 @@ class Guest extends BaseUser implements ManageableGuest, Registerable { // No activity will be logged for guest accounts } - /** - * Flushs all pending updates to the database layer - * - * @return void - */ - public function flushPendingUpdates () { - // No updates will be flushed to database! - } - }