1 | <?php |
||
10 | trait HasApiTokens |
||
11 | { |
||
12 | /** |
||
13 | * The current access token for the authentication user. |
||
14 | * |
||
15 | * @var \Rinvex\Oauth\Models\AccessToken |
||
16 | */ |
||
17 | protected $accessToken; |
||
18 | |||
19 | /** |
||
20 | * Get all of the user's registered OAuth clients. |
||
21 | * |
||
22 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
23 | */ |
||
24 | public function clients(): MorphMany |
||
28 | |||
29 | /** |
||
30 | * Get all of the access tokens for the user. |
||
31 | * |
||
32 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
33 | */ |
||
34 | public function tokens(): MorphMany |
||
38 | |||
39 | /** |
||
40 | * Get the current access token being used by the user. |
||
41 | * |
||
42 | * @return \Rinvex\Oauth\Models\AccessToken|null |
||
43 | */ |
||
44 | public function token() |
||
48 | |||
49 | /** |
||
50 | * Create a new personal access token for the user. |
||
51 | * |
||
52 | * @param string $name |
||
53 | * @param array $scopes |
||
54 | * |
||
55 | * @throws \Illuminate\Contracts\Container\BindingResolutionException |
||
56 | * |
||
57 | * @return \Rinvex\Oauth\PersonalAccessTokenResult |
||
58 | */ |
||
59 | public function createToken($name, array $scopes = []) |
||
63 | |||
64 | /** |
||
65 | * Set the current access token for the user. |
||
66 | * |
||
67 | * @param \Rinvex\Oauth\Models\AccessToken $accessToken |
||
68 | * |
||
69 | * @return $this |
||
70 | */ |
||
71 | public function withAccessToken($accessToken) |
||
77 | } |
||
78 |
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.