From db9326c956b3a1021c178372ee8b9ba9a8e14b07 Mon Sep 17 00:00:00 2001 From: Yuan Chiu Date: Sat, 26 Jul 2014 10:54:17 -0700 Subject: [PATCH] User Class (not tested) --- htdocs/lib/User/Exceptions.php | 74 +++++++++++++++++++++++++++++++++ htdocs/lib/User/UserControl.php | 2 +- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 htdocs/lib/User/Exceptions.php diff --git a/htdocs/lib/User/Exceptions.php b/htdocs/lib/User/Exceptions.php new file mode 100644 index 0000000..e38f461 --- /dev/null +++ b/htdocs/lib/User/Exceptions.php @@ -0,0 +1,74 @@ +userId = $userId; + parent::__construct($description); + } + + /** + * 取得輸入的資料庫系統名稱 + * @return string 錯誤訊息內容 + */ + public function getUserId() { + return $this->userId; + } +} + +// 使用者登入 ====================================================================== +/** + * 沒有找到此帳號 + * @since 3.0.0 + */ +class UserNoFoundException extends UserException { + public function __construct($userId) { + parent::__construct($userId, 'User: "'.$this->type.'" is no found.'); + } +} + + +/** + * 使用者登入密碼錯誤 + * @since 3.0.0 + */ +class UserPasswordErrException extends UserException { + public function __construct($userId) { + parent::__construct($userId, 'User: "'.$this->type.'" password is wrong.'); + } +} + +// 建立使用者 ====================================================================== +/** + * 已有重複的使用者名稱 + * @since 3.0.0 + */ +class UserIdExistException extends UserException { + public function __construct($userId) { + parent::__construct($userId, 'UserId: "'.$this->type.'" is exist.'); + } +} + diff --git a/htdocs/lib/User/UserControl.php b/htdocs/lib/User/UserControl.php index 5c5a5d9..7c39ffd 100644 --- a/htdocs/lib/User/UserControl.php +++ b/htdocs/lib/User/UserControl.php @@ -32,7 +32,7 @@ class UserControl { * @return bool 已有相同的帳號名稱 * @since 3.0.0 */ - public function isHave($userName) { + public function isExist($userName) { // TODO: Fill code in }