X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Fuser%2Fguest%2Fclass_Guest.php;h=0ffd9eaea0728309fede32fa46ee74ccde5b6521;hp=c7fb4b22b50ea879a3d2fda88fc574839daf0c85;hb=refs%2Fheads%2Fmaster;hpb=59b2c91c330849915cb257ed7137ea9e5ce1a5b8 diff --git a/framework/main/classes/user/guest/class_Guest.php b/framework/main/classes/user/guest/class_Guest.php index c7fb4b22..0ffd9eae 100644 --- a/framework/main/classes/user/guest/class_Guest.php +++ b/framework/main/classes/user/guest/class_Guest.php @@ -3,18 +3,22 @@ namespace Org\Mxchange\CoreFramework\User\Guest; // Import framework stuff +use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Manager\Guest\ManageableGuest; use Org\Mxchange\CoreFramework\Registry\Registerable; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\User\BaseUser; use Org\Mxchange\CoreFramework\User\UsernameMissingException; +// Import SPL stuff +use \InvalidArgumentException; + /** * A generic class for handling guests * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 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 * @@ -43,7 +47,7 @@ class Guest extends BaseUser implements ManageableGuest, Registerable { * * @return void */ - protected function __construct () { + private function __construct () { // Call parent constructor parent::__construct(__CLASS__); } @@ -84,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(); @@ -111,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(); @@ -124,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 @@ -134,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! - } - }