* @version 0.0.0 * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ class User extends BaseFrameworkSystem implements ManageableUser { /** * Username */ private $username = ""; // Exceptions const EXCEPTION_USERNAME_NOT_FOUND = 0xd00; /** * Private constructor * * @return void */ protected function __construct ($class = "") { // Is the class name empty? Then this is not a specialized user class if (empty($class)) $class = __CLASS__; // Call parent constructor parent::__construct($class); // Set part description $this->setObjectDescription("Generic user class"); // Create unique ID number $this->createUniqueID(); // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); } /** * Creates an instance of this user class by a provided username. This * factory method will check if the username is already taken and if not * so it will throw an exception. * * @param $username Username we need a class instance for * @return $userInstance An instance of this user class * @throws UsernameMissingException If the username does not exist */ public final static function createUserByUsername ($userName) { // Get a new instance $userInstance = new User(); // Set the username $userInstance->setUsername($userName); // Check if the username exists if (!$userInstance->ifUsernameExists()) { // Throw an exception here throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); } // Return the instance return $userInstance; } /** * Setter for username * * @param $userName The username to set * @return void */ protected final function setUsername ($userName) { $this->userNane = $userName; } /** * Getter for username * * @return $userName The username to set */ public final function getUsername () { return $this->userNane; } } // [EOF] ?>