1 | <?php |
||
6 | trait UserEntity |
||
7 | { |
||
8 | /** |
||
9 | * The default avatar used when there is no avatar for the user. |
||
10 | * |
||
11 | * @var string |
||
12 | */ |
||
13 | protected $defaultAvatar = '/images/avatar.png'; |
||
14 | |||
15 | /** |
||
16 | * Get the small avatar. |
||
17 | * |
||
18 | * @return string |
||
19 | */ |
||
20 | public function getAvatarSmallAttribute(): string |
||
24 | |||
25 | /** |
||
26 | * Get the medium avatar. |
||
27 | * |
||
28 | * @return string |
||
29 | */ |
||
30 | public function getAvatarMediumAttribute(): string |
||
34 | |||
35 | /** |
||
36 | * Get the big avatar. |
||
37 | * |
||
38 | * @return string |
||
39 | */ |
||
40 | public function getAvatarBigAttribute(): string |
||
44 | |||
45 | /** |
||
46 | * Get the porofile background. |
||
47 | * |
||
48 | * @return string |
||
49 | */ |
||
50 | public function getProfileBackgroundAttribute(): string |
||
54 | |||
55 | protected function parseMedia(string $type): string |
||
63 | } |
||
64 |
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.