4
4
5
5
use Illuminate \Contracts \Auth \Authenticatable as AuthenticatableContract ;
6
6
use Illuminate \Contracts \Mail \Mailer as MailerContract ;
7
- use Illuminate \Mail \Message ;
8
7
use Illuminate \Database \Schema \Builder ;
9
8
use Illuminate \Support \Str ;
10
- use Jrean \UserVerification \VerificationException ;
11
9
12
10
class UserVerification
13
11
{
@@ -21,15 +19,15 @@ class UserVerification
21
19
/**
22
20
* Schema builder instance.
23
21
*
24
- * @var \Illuminate\Database\Schema\Builder $schema
22
+ * @var \Illuminate\Database\Schema\Builder
25
23
*/
26
24
protected $ schema ;
27
25
28
26
/**
29
27
* Constructor.
30
28
*
31
- * @param \Illuminate\Contracts\Mail\Mailer $mailer
32
- * @param \Illuminate\Database\Schema\Builder $schema
29
+ * @param \Illuminate\Contracts\Mail\Mailer $mailer
30
+ * @param \Illuminate\Database\Schema\Builder $schema
33
31
*
34
32
* @return void
35
33
*/
@@ -43,8 +41,9 @@ public function __construct(MailerContract $mailer, Builder $schema)
43
41
/**
44
42
* Generate and save a verification token the given user.
45
43
*
46
- * @param \Illuminate\Contracts\Auth\Authenticatable $model
47
- * @return boolean
44
+ * @param \Illuminate\Contracts\Auth\Authenticatable $model
45
+ *
46
+ * @return bool
48
47
*/
49
48
public function generate (AuthenticatableContract $ model )
50
49
{
@@ -54,14 +53,15 @@ public function generate(AuthenticatableContract $model)
54
53
/**
55
54
* Send by email a link containing the verification token.
56
55
*
57
- * @param \Illuminate\Contracts\Auth\Authenticatable $model
58
- * @param string $subject
59
- * @return boolean
56
+ * @param \Illuminate\Contracts\Auth\Authenticatable $model
57
+ * @param string $subject
58
+ *
59
+ * @return bool
60
60
*/
61
61
public function send (AuthenticatableContract $ model , $ subject = null )
62
62
{
63
- if ( ! $ this ->isCompliant ($ model )) {
64
- throw new VerificationException ;
63
+ if (! $ this ->isCompliant ($ model )) {
64
+ throw new VerificationException () ;
65
65
}
66
66
67
67
return (boolean ) $ this ->emailVerificationLink ($ model , $ subject );
@@ -70,13 +70,14 @@ public function send(AuthenticatableContract $model, $subject = null)
70
70
/**
71
71
* Process the token verification.
72
72
*
73
- * @param \Illuminate\Contracts\Auth\Authenticatable $model
74
- * @param string $token
75
- * @return boolean
73
+ * @param \Illuminate\Contracts\Auth\Authenticatable $model
74
+ * @param string $token
75
+ *
76
+ * @return bool
76
77
*/
77
78
public function process (AuthenticatableContract $ model , $ token )
78
79
{
79
- if ( ! $ this ->compareToken ($ model ->verification_token , $ token )) {
80
+ if (! $ this ->compareToken ($ model ->verification_token , $ token )) {
80
81
return false ;
81
82
}
82
83
@@ -88,8 +89,9 @@ public function process(AuthenticatableContract $model, $token)
88
89
/**
89
90
* Check if the user is verified.
90
91
*
91
- * @param \Illuminate\Contracts\Auth\Authenticatable $model
92
- * @return boolean
92
+ * @param \Illuminate\Contracts\Auth\Authenticatable $model
93
+ *
94
+ * @return bool
93
95
*/
94
96
public function isVerified (AuthenticatableContract $ model )
95
97
{
@@ -100,6 +102,7 @@ public function isVerified(AuthenticatableContract $model)
100
102
* Update and save the model instance has verified.
101
103
*
102
104
* @param AuthenticatableContract $model
105
+ *
103
106
* @return void
104
107
*/
105
108
protected function wasVerified (AuthenticatableContract $ model )
@@ -114,9 +117,10 @@ protected function wasVerified(AuthenticatableContract $model)
114
117
/**
115
118
* Compare the verification token given by the user with the one stored.
116
119
*
117
- * @param string $storedToken
118
- * @param string $requestToken
119
- * @return boolean
120
+ * @param string $storedToken
121
+ * @param string $requestToken
122
+ *
123
+ * @return bool
120
124
*/
121
125
protected function compareToken ($ storedToken , $ requestToken )
122
126
{
@@ -126,8 +130,9 @@ protected function compareToken($storedToken, $requestToken)
126
130
/**
127
131
* Prepare and send the email with the verification token link.
128
132
*
129
- * @param \Illuminate\Contracts\Auth\Authenticatable $model
130
- * @param string $subject
133
+ * @param \Illuminate\Contracts\Auth\Authenticatable $model
134
+ * @param string $subject
135
+ *
131
136
* @return mixed
132
137
*/
133
138
protected function emailVerificationLink (AuthenticatableContract $ model , $ subject )
@@ -152,15 +157,17 @@ protected function generateToken()
152
157
/**
153
158
* Update and save the model instance with the verification token.
154
159
*
155
- * @param \Illuminate\Contracts\Auth\Authenticatable $model
156
- * @param string $token
157
- * @return boolean
160
+ * @param \Illuminate\Contracts\Auth\Authenticatable $model
161
+ * @param string $token
162
+ *
158
163
* @throws \Jrean\UserVerification\Exceptions\VerificationException
164
+ *
165
+ * @return bool
159
166
*/
160
167
protected function saveToken (AuthenticatableContract $ model , $ token )
161
168
{
162
- if ( ! $ this ->isCompliant ($ model )) {
163
- throw new VerificationException ;
169
+ if (! $ this ->isCompliant ($ model )) {
170
+ throw new VerificationException () ;
164
171
}
165
172
166
173
$ model ->verification_token = $ token ;
@@ -172,8 +179,9 @@ protected function saveToken(AuthenticatableContract $model, $token)
172
179
* Determine if the given model table has the verified and verification_token
173
180
* columns.
174
181
*
175
- * @param \Illuminate\Contracts\Auth\Authenticatable $model
176
- * @return boolean
182
+ * @param \Illuminate\Contracts\Auth\Authenticatable $model
183
+ *
184
+ * @return bool
177
185
*/
178
186
protected function isCompliant (AuthenticatableContract $ model )
179
187
{
@@ -190,9 +198,10 @@ protected function isCompliant(AuthenticatableContract $model)
190
198
/**
191
199
* Check if the given model talbe has the given column.
192
200
*
193
- * @param \Illuminate\Contracts\Auth\Authenticatable $model
194
- * @param string $column
195
- * @return boolean
201
+ * @param \Illuminate\Contracts\Auth\Authenticatable $model
202
+ * @param string $column
203
+ *
204
+ * @return bool
196
205
*/
197
206
protected function hasColumn (AuthenticatableContract $ model , $ column )
198
207
{
0 commit comments