1 | <?php |
||
9 | trait MustVerifyNewEmail |
||
10 | { |
||
11 | /** |
||
12 | * Deletes all previous attempts for this user, creates a new model/token |
||
13 | * to verify the given email address and send the verification URL |
||
14 | * to the new email address. |
||
15 | * |
||
16 | * @param string $email |
||
17 | * @return \Illuminate\Database\Eloquent\Model|null |
||
18 | */ |
||
19 | public function newEmail(string $email): ?Model |
||
29 | |||
30 | public function getEmailVerificationModel(): Model |
||
40 | |||
41 | /** |
||
42 | * Creates new PendingUserModel model for the given email. |
||
43 | * |
||
44 | * @param string $email |
||
45 | * @return \Illuminate\Database\Eloquent\Model |
||
46 | */ |
||
47 | public function createPendingUserEmailModel(string $email): Model |
||
58 | |||
59 | /** |
||
60 | * Returns the pending email address. |
||
61 | * |
||
62 | * @return string|null |
||
63 | */ |
||
64 | public function getPendingEmail(): ?string |
||
68 | |||
69 | /** |
||
70 | * Deletes the pending email address models for this user. |
||
71 | * |
||
72 | * @return void |
||
73 | */ |
||
74 | public function clearPendingEmail() |
||
78 | |||
79 | /** |
||
80 | * Sends the VerifyNewEmail Mailable to the new email address. |
||
81 | * |
||
82 | * @param \Illuminate\Database\Eloquent\Model $pendingUserEmail |
||
83 | * @return mixed |
||
84 | */ |
||
85 | public function sendPendingEmailVerificationMail(Model $pendingUserEmail) |
||
97 | |||
98 | /** |
||
99 | * Grabs the pending user email address, generates a new token and sends the Mailable. |
||
100 | * |
||
101 | * @return \Illuminate\Database\Eloquent\Model|null |
||
102 | */ |
||
103 | public function resendPendingEmailVerificationMail(): ?Model |
||
109 | } |
||
110 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.