@@ -14,41 +14,29 @@ class UserTokenService
1414{
1515 /**
1616 * Name of table where user tokens are stored.
17- *
18- * @var string
1917 */
20- protected $ tokenTable = 'user_tokens ' ;
18+ protected string $ tokenTable = 'user_tokens ' ;
2119
2220 /**
2321 * Token expiry time in hours.
24- *
25- * @var int
2622 */
27- protected $ expiryTime = 24 ;
23+ protected int $ expiryTime = 24 ;
2824
2925 /**
30- * Delete all email confirmations that belong to a user.
31- *
32- * @param User $user
33- *
34- * @return mixed
26+ * Delete all tokens that belong to a user.
3527 */
36- public function deleteByUser (User $ user )
28+ public function deleteByUser (User $ user ): void
3729 {
38- return DB ::table ($ this ->tokenTable )
30+ DB ::table ($ this ->tokenTable )
3931 ->where ('user_id ' , '= ' , $ user ->id )
4032 ->delete ();
4133 }
4234
4335 /**
44- * Get the user id from a token, while check the token exists and has not expired.
45- *
46- * @param string $token
36+ * Get the user id from a token, while checking the token exists and has not expired.
4737 *
4838 * @throws UserTokenNotFoundException
4939 * @throws UserTokenExpiredException
50- *
51- * @return int
5240 */
5341 public function checkTokenAndGetUserId (string $ token ): int
5442 {
@@ -67,8 +55,6 @@ public function checkTokenAndGetUserId(string $token): int
6755
6856 /**
6957 * Creates a unique token within the email confirmation database.
70- *
71- * @return string
7258 */
7359 protected function generateToken (): string
7460 {
@@ -82,10 +68,6 @@ protected function generateToken(): string
8268
8369 /**
8470 * Generate and store a token for the given user.
85- *
86- * @param User $user
87- *
88- * @return string
8971 */
9072 protected function createTokenForUser (User $ user ): string
9173 {
@@ -102,10 +84,6 @@ protected function createTokenForUser(User $user): string
10284
10385 /**
10486 * Check if the given token exists.
105- *
106- * @param string $token
107- *
108- * @return bool
10987 */
11088 protected function tokenExists (string $ token ): bool
11189 {
@@ -115,12 +93,8 @@ protected function tokenExists(string $token): bool
11593
11694 /**
11795 * Get a token entry for the given token.
118- *
119- * @param string $token
120- *
121- * @return object|null
12296 */
123- protected function getEntryByToken (string $ token )
97+ protected function getEntryByToken (string $ token ): ? stdClass
12498 {
12599 return DB ::table ($ this ->tokenTable )
126100 ->where ('token ' , '= ' , $ token )
@@ -129,10 +103,6 @@ protected function getEntryByToken(string $token)
129103
130104 /**
131105 * Check if the given token entry has expired.
132- *
133- * @param stdClass $tokenEntry
134- *
135- * @return bool
136106 */
137107 protected function entryExpired (stdClass $ tokenEntry ): bool
138108 {
0 commit comments