]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blob - lib/Channel.php
Replace a stray "response" prop with "result"
[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 implements Contracts\User
9 {
10
11 public Connection $connection;
12
13 public function __construct(string $uri, string $api_login, array $options)
14 {
15 $this->connection = new Connection($uri, $api_login, $options);
16 }
17
18 /**
19 * Return a list of channels users.
20 *
21 * @return stdClass
22 * @throws Exception
23 */
24 public function get(): 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 * Return a channel object
37 *
38 * @param array $params
39 * @return stdClass
40 * @throws Exception
41 */
42 public function show(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 }