]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/commitdiff
Add $rpc->stats()->get();
authorBram Matthys <redacted>
Wed, 12 Apr 2023 06:31:52 +0000 (08:31 +0200)
committerBram Matthys <redacted>
Wed, 12 Apr 2023 06:31:52 +0000 (08:31 +0200)
lib/Connection.php
lib/Stats.php [new file with mode: 0644]

index e5d5805154396799dd78a7f18c6952c85256ce9b..dcfb14740ab26de1f451f8e82be19fefdea72f1c 100644 (file)
@@ -142,6 +142,11 @@ class Connection
         return new Rpc($this);
     }
 
+    public function stats(): Stats
+    {
+        return new Stats($this);
+    }
+
     public function user(): User
     {
         return new User($this);
@@ -161,18 +166,22 @@ class Connection
     {
         return new Spamfilter($this);
     }
+
     public function nameban(): NameBan
     {
         return new NameBan($this);
     }
+
     public function server(): Server
     {
         return new Server($this);
     }
+
     public function serverbanexception(): ServerBanException
     {
         return new ServerBanException($this);
     }
+
     public function log(): Log
     {
         return new Log($this);
diff --git a/lib/Stats.php b/lib/Stats.php
new file mode 100644 (file)
index 0000000..a4f5656
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+
+namespace UnrealIRCd;
+
+use Exception;
+use stdClass;
+
+class Stats
+{
+
+    public Connection $connection;
+
+    public function __construct(Connection $conn)
+    {
+        $this->connection = $conn;
+    }
+
+    /**
+     * Get basic statistical information: user counts, channel counts, etc.
+     *
+     * @return stdClass|array|bool
+     */
+    public function get(int $object_detail_level=1): stdClass|array|bool
+    {
+        $response = $this->connection->query('stats.get', [
+            'object_detail_level' => $object_detail_level,
+        ]);
+    }
+}