From: Denver F Date: Wed, 17 Aug 2022 15:35:25 +0000 (+0100) Subject: Added version to composer.json and a couple of small (hopefully non-breaking) changes X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-rpc-php.git/commitdiff_plain/refs/pull/5/head Added version to composer.json and a couple of small (hopefully non-breaking) changes --- diff --git a/composer.json b/composer.json index 30ee372..92b21b7 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,6 @@ { "name": "unrealircd/unrealircd-rpc", + "version": "0.1.0", "description": "JSON-RPC interface to UnrealIRCd", "type": "library", "require": { @@ -16,6 +17,10 @@ { "name": "Bram Matthys", "email": "syzop@vulnscan.org" + }, + { + "name": "Denver Freeburn", + "email": "sketch@sketchni.uk" } ], "support": { diff --git a/lib/Ban.php b/lib/Ban.php index 0519872..2a2272c 100644 --- a/lib/Ban.php +++ b/lib/Ban.php @@ -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; } /** diff --git a/lib/Connection.php b/lib/Connection.php index d9a7342..7832e9d 100644 --- a/lib/Connection.php +++ b/lib/Connection.php @@ -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);