]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blame - lib/Channel.php
Merge pull request #5 from unrealircd/wip
[irc/unrealircd/unrealircd-rpc-php.git] / lib / Channel.php
CommitLineData
8d5a112f
D
1<?php
2
3namespace UnrealIRCd;
4
5use Exception;
80bc3098 6use stdClass;
8d5a112f
D
7
8class 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 *
80bc3098 21 * @return stdClass
8d5a112f
D
22 * @throws Exception
23 */
80bc3098 24 public function get(): stdClass
8d5a112f 25 {
267b314e 26 $response = $this->connection->query('channel.list');
8d5a112f 27
8d5a112f
D
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
80bc3098 39 * @return stdClass
8d5a112f
D
40 * @throws Exception
41 */
80bc3098 42 public function show(array $params): stdClass
8d5a112f 43 {
267b314e 44 $response = $this->connection->query('channel.get', ['channel' => $params['channel']]);
8d5a112f 45
8d5a112f
D
46 if (!is_bool($response)) {
47 return $response;
48 }
49
50 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
51 }
52}