1 | <?php |
||
7 | trait Followable |
||
8 | { |
||
9 | /** |
||
10 | * Follow a user. |
||
11 | * |
||
12 | * @param int|array $user |
||
13 | */ |
||
14 | 18 | public function follow($user) |
|
22 | |||
23 | /** |
||
24 | * Unfollow a user. |
||
25 | * |
||
26 | * @param $user |
||
27 | */ |
||
28 | 3 | public function unfollow($user) |
|
36 | |||
37 | /** |
||
38 | * Check if user is following given user. |
||
39 | * |
||
40 | * @param $user |
||
41 | * @return mixed |
||
42 | */ |
||
43 | 3 | public function isFollowing($user) |
|
47 | |||
48 | /** |
||
49 | * Check if user is followed by given user. |
||
50 | * |
||
51 | * @param $user |
||
52 | * @return mixed |
||
53 | */ |
||
54 | 3 | public function isFollowedBy($user) |
|
58 | |||
59 | /** |
||
60 | * Followers relationship. |
||
61 | * |
||
62 | * @return mixed |
||
63 | */ |
||
64 | 12 | public function followers() |
|
70 | |||
71 | /** |
||
72 | * Followings relationship. |
||
73 | * |
||
74 | * @return mixed |
||
75 | */ |
||
76 | 18 | public function followings() |
|
82 | } |
||
83 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: