]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/user/guest/class_Guest.php
Continued:
[core.git] / framework / main / classes / user / guest / class_Guest.php
index 60192e00a72b5a76ab02f0cd6146567659cc4d82..0ffd9eaea0728309fede32fa46ee74ccde5b6521 100644 (file)
@@ -3,17 +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 <webmaster@shipsimu.org>
  * @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
  *
@@ -42,7 +47,7 @@ class Guest extends BaseUser implements ManageableGuest, Registerable {
         *
         * @return      void
         */
-       protected function __construct () {
+       private function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
        }
@@ -83,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();
 
@@ -110,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();
 
@@ -123,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
@@ -133,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!
-       }
-
 }