]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blob - lib/Log.php
Fix wrong function arguments (well, will be changed at some point)
[irc/unrealircd/unrealircd-rpc-php.git] / lib / Log.php
1 <?php
2
3 namespace UnrealIRCd;
4
5 use Exception;
6 use stdClass;
7
8 class Log
9 {
10
11 public Connection $connection;
12
13 public function __construct(Connection $conn)
14 {
15 $this->connection = $conn;
16 }
17
18 /**
19 * Subscribe to log events.
20 * Any previous subscriptions are overwritten (lost).
21 *
22 * @return stdClass|array|bool
23 */
24 public function subscribe(array $sources): stdClass|array|bool
25 {
26 return $this->connection->query('log.subscribe', [
27 'sources' => $sources,
28 ]);
29 }
30
31 /**
32 * Unsubscribe from all log events.
33 *
34 * @return stdClass|array|bool
35 */
36 public function unsubscribe(string $name): stdClass|array|bool
37 {
38 return $this->connection->query('log.unsubscribe');
39 }
40
41 /**
42 * Get past log events.
43 *
44 * @return stdClass|array|bool
45 */
46 public function getAll(): stdClass|array|bool
47 {
48 $response = $this->connection->query('log.list', []);
49
50 if (!is_bool($response) && property_exists($response, 'list'))
51 return $response->list;
52
53 return false;
54 }
55 }