]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blob - lib/Channel.php
Get rid of PHP Contracts
[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
22 * @throws Exception
23 */
24 public function getAll(): stdClass
25 {
26 $response = $this->connection->query('channel.list');
27
28 if(!is_bool($response)) {
29 return $response;
30 }
31
32 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
33 }
34
35 /**
36 * Get a channel object
37 *
38 * @param array $params
39 * @return stdClass
40 * @throws Exception
41 */
42 public function get(array $params): stdClass
43 {
44 $response = $this->connection->query('channel.get', ['channel' => $params['channel']]);
45
46 if (!is_bool($response)) {
47 return $response;
48 }
49
50 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
51 }
52 }