1 | <?php |
||
10 | class PresenceChannel extends PrivateChannel |
||
11 | { |
||
12 | /** |
||
13 | * Subscribe to the channel. |
||
14 | * |
||
15 | * @see https://pusher.com/docs/pusher_protocol#presence-channel-events |
||
16 | * @param \Ratchet\ConnectionInterface $connection |
||
17 | * @param \stdClass $payload |
||
18 | * @return void |
||
19 | * @throws InvalidSignature |
||
20 | */ |
||
21 | public function subscribe(ConnectionInterface $connection, stdClass $payload) |
||
60 | |||
61 | /** |
||
62 | * Unsubscribe connection from the channel. |
||
63 | * |
||
64 | * @param \Ratchet\ConnectionInterface $connection |
||
65 | * @return void |
||
66 | */ |
||
67 | public function unsubscribe(ConnectionInterface $connection) |
||
98 | |||
99 | /** |
||
100 | * Get the Presence channel data. |
||
101 | * |
||
102 | * @param array $users |
||
103 | * @return array |
||
104 | */ |
||
105 | protected function getChannelData(array $users): array |
||
115 | |||
116 | /** |
||
117 | * Get the Presence Channel's users. |
||
118 | * |
||
119 | * @param array $users |
||
120 | * @return array |
||
121 | */ |
||
122 | protected function getUserIds(array $users): array |
||
130 | |||
131 | /** |
||
132 | * Compute the hash for the presence channel integrity. |
||
133 | * |
||
134 | * @param array $users |
||
135 | * @return array |
||
136 | */ |
||
137 | protected function getHash(array $users): array |
||
147 | } |
||
148 |
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: