]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blob - lib/Channel.php
Make getAll() return the list of users without wrapping it under a 'list' item.
[irc/unrealircd/unrealircd-rpc-php.git] / lib / Channel.php
1 <?php
2
3 namespace UnrealIRCd;
4
5 use Exception;
6 use stdClass;
7
8 class Channel
9 {
10
11 public Connection $connection;
12
13 public function __construct(Connection $conn)
14 {
15 $this->connection = $conn;
16 }
17
18 /**
19 * Return a list of channels users.
20 *
21 * @return stdClass|array|bool
22 * @throws Exception
23 */
24 public function getAll(): stdClass|array|bool
25 {
26 $response = $this->connection->query('channel.list');
27
28 if(!is_bool($response)) {
29 return $response->list;
30 }
31
32 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
33 }
34
35 /**
36 * Get a channel object
37 *
38 * @return stdClass|array|bool
39 * @throws Exception
40 */
41 public function get(string $channel): stdClass|array|bool
42 {
43 $response = $this->connection->query('channel.get', ['channel' => $channel]);
44
45 if (!is_bool($response)) {
46 return $response;
47 }
48
49 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
50 }
51 }