]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blame - lib/Channel.php
Get rid of PHP Contracts
[irc/unrealircd/unrealircd-rpc-php.git] / lib / Channel.php
CommitLineData
8d5a112f
D
1<?php
2
3namespace UnrealIRCd;
4
5use Exception;
80bc3098 6use stdClass;
8d5a112f 7
78796043 8class Channel
8d5a112f
D
9{
10
11 public Connection $connection;
12
7c7017a2 13 public function __construct(Connection $conn)
8d5a112f 14 {
7c7017a2 15 $this->connection = $conn;
8d5a112f
D
16 }
17
18 /**
19 * Return a list of channels users.
20 *
80bc3098 21 * @return stdClass
8d5a112f
D
22 * @throws Exception
23 */
7c7017a2 24 public function getAll(): 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 /**
7c7017a2 36 * Get a channel object
8d5a112f
D
37 *
38 * @param array $params
80bc3098 39 * @return stdClass
8d5a112f
D
40 * @throws Exception
41 */
7c7017a2 42 public function get(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}