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 \ProtoneMedia\LaravelVerifyNewEmail\PendingUserEmail|null |
||
18 | */ |
||
19 | public function newEmail(string $email):?PendingUserEmail |
||
31 | |||
32 | /** |
||
33 | * Createsa new PendingUserModel model for the given email. |
||
34 | * |
||
35 | * @param string $email |
||
36 | * @return \ProtoneMedia\LaravelVerifyNewEmail\PendingUserEmail |
||
37 | */ |
||
38 | public function createPendingUserEmailModel(string $email): PendingUserEmail |
||
47 | |||
48 | /** |
||
49 | * Returns the pending email address. |
||
50 | * |
||
51 | * @return string|null |
||
52 | */ |
||
53 | public function getPendingEmail():?string |
||
57 | |||
58 | /** |
||
59 | * Deletes the pending email address models for this user. |
||
60 | * |
||
61 | * @return void |
||
62 | */ |
||
63 | public function clearPendingEmail() |
||
67 | |||
68 | /** |
||
69 | * Sends the VerifyNewEmail Mailable to the new email address. |
||
70 | * |
||
71 | * @param \ProtoneMedia\LaravelVerifyNewEmail\PendingUserEmail $pendingUserEmail |
||
72 | * @return mixed |
||
73 | */ |
||
74 | public function sendPendingEmailVerificationMail(PendingUserEmail $pendingUserEmail) |
||
86 | |||
87 | /** |
||
88 | * Grabs the pending user email address, generates a new token and sends the Mailable. |
||
89 | * |
||
90 | * @return \ProtoneMedia\LaravelVerifyNewEmail\PendingUserEmail|null |
||
91 | */ |
||
92 | public function resendPendingEmailVerificationMail():?PendingUserEmail |
||
98 | } |
||
99 |
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.