]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/commitdiff
Added version to composer.json and a couple of small (hopefully non-breaking) changes
authorDenver F <redacted>
Wed, 17 Aug 2022 15:35:25 +0000 (16:35 +0100)
committerDenver F <redacted>
Wed, 17 Aug 2022 15:35:25 +0000 (16:35 +0100)
composer.json
lib/Ban.php
lib/Connection.php

index 30ee372e12d9d3410aa815394519c543856dd5cd..92b21b77f1920adb787a98594c2cb1033cc4d005 100644 (file)
@@ -1,5 +1,6 @@
 {
     "name": "unrealircd/unrealircd-rpc",
+    "version": "0.1.0",
     "description": "JSON-RPC interface to UnrealIRCd",
     "type": "library",
     "require": {
         {
             "name": "Bram Matthys",
             "email": "syzop@vulnscan.org"
+        },
+        {
+            "name": "Denver Freeburn",
+            "email": "sketch@sketchni.uk"
         }
     ],
     "support": {
index 05198729d36b5ca7db8612b1790d51aa5de3e33a..2a2272caeb4254a99f511e3f4e17a8606720657f 100644 (file)
@@ -25,14 +25,12 @@ class Ban implements Contracts\Ban
      */
     public function add(string $user, array $params): stdClass
     {
-        $response = $this->connection->query('server_ban.add', [
+        return $this->connection->query('server_ban.add', [
             'name' => $user,
             'type' => $params['type'],
             'reason' => $params['reason'],
             'duration_string' => $params['length'] ?? '1d',
         ]);
-
-        return $response;
     }
 
     /**
@@ -45,12 +43,10 @@ class Ban implements Contracts\Ban
      */
     public function delete(string $user, array $params): stdClass
     {
-        $response = $this->connection->query('server_ban.del', [
+        return $this->connection->query('server_ban.del', [
             'name' => $user,
             'type' => $params['type'],
         ]);
-
-        return $response;
     }
 
     /**
index d9a7342a531d8103d7c6adcbad84f6ce72ddb0b9..7832e9df8c74f0f159b36e97631291928c9e0c77 100644 (file)
@@ -9,7 +9,7 @@ class Connection
 {
     protected WebSocket\Client $connection;
 
-    public function __construct(string $uri, string $api_login, array $options)
+    public function __construct(string $uri, string $api_login, array $options = null)
     {
         $context = $options["context"] ?? stream_context_create();
 
@@ -34,11 +34,12 @@ class Connection
      * @note I'm not sure on the response type except that it may be either an object or array.
      *
      * @param  string  $method
-     * @param  array  $params
+     * @param  array|null  $params
+     *
      * @return object|array|bool
      * @throws Exception
      */
-    public function query(string $method, array $params): object|array|bool
+    public function query(string $method, array|null $params = null): object|array|bool
     {
         $id = random_int(1, 99999);