* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class User extends BaseFrameworkSystem implements ManageableUser {
+class User extends BaseFrameworkSystem implements ManageableUser, Registerable {
/**
- * Username
+ * Username of current user
*/
- private $username = "";
+ private $userName = "";
+
+ /**
+ * Email of current user
+ */
+ private $email = "";
// Exceptions
const EXCEPTION_USERNAME_NOT_FOUND = 0xd00;
* 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
+ * @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
*/
return $userInstance;
}
+ /**
+ * Creates an instance of this user class by a provided email address. This
+ * factory method will not check if the email address is there.
+ *
+ * @param $email Email address of the user
+ * @return $userInstance An instance of this user class
+ */
+ public final static function createUserByEmail ($email) {
+ // Get a new instance
+ $userInstance = new User();
+
+ // Set the username
+ $userInstance->setEmail($email);
+
+ // Return the instance
+ return $userInstance;
+ }
+
/**
* Setter for username
*
* @return void
*/
protected final function setUsername ($userName) {
- $this->userNane = $userName;
+ $this->UserName = $userName;
+ }
+
+ /**
+ * Setter for email
+ *
+ * @param $email The email to set
+ * @return void
+ */
+ protected final function setEmail ($email) {
+ $this->userName = $email;
}
/**
* @return $userName The username to get
*/
public final function getUsername () {
- return $this->userNane;
+ return $this->userName;
+ }
+
+ /**
+ * Getter for email
+ *
+ * @return $email The email to get
+ */
+ public final function getEmail () {
+ return $this->email;
}
/**
*
* @return $exists Wether the username exists
*/
- protected function ifUsernameExists () {
+ public function ifUsernameExists () {
// By default the username does exist
$exists = true;