]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blobdiff - lib/ServerBan.php
Make getAll() return the list of users without wrapping it under a 'list' item.
[irc/unrealircd/unrealircd-rpc-php.git] / lib / ServerBan.php
index 46c922f5d81fcf84e5402a0ddbc429e2aeeb64bc..126692ad5e3fb341dcd7f7a80611834a6dab4288 100644 (file)
@@ -5,7 +5,7 @@ namespace UnrealIRCd;
 use Exception;
 use stdClass;
 
-class ServerBan implements Contracts\ServerBan
+class ServerBan
 {
 
     public Connection $connection;
@@ -19,48 +19,46 @@ class ServerBan implements Contracts\ServerBan
      * Add a ban.
      *
      * @param  string  $user
-     * @param  array  $params
-     * @return stdClass
+     * @return stdClass|array|bool
      * @throws Exception
      */
-    public function add(string $user, array $params): stdClass
+    public function add(string $name, string $type, string $duration, string $reason): stdClass|array|bool
     {
         return $this->connection->query('server_ban.add', [
-            'name' => $user,
-            'type' => $params['type'],
-            'reason' => $params['reason'],
-            'duration_string' => $params['length'] ?? '1d',
+            'name' => $name,
+            'type' => $type,
+            'reason' => $reason,
+            'duration_string' => $duration ?? '1d',
         ]);
     }
 
     /**
      * Delete a ban.
      *
-     * @param  string  $user
-     * @param  array  $params
-     * @return stdClass
+     * @param  string  $name
+     * @return stdClass|array|bool
      * @throws Exception
      */
-    public function delete(string $user, array $params): stdClass
+    public function delete(string $name, string $type): stdClass|array|bool
     {
         return $this->connection->query('server_ban.del', [
-            'name' => $user,
-            'type' => $params['type'],
+            'name' => $name,
+            'type' => $type,
         ]);
     }
 
     /**
      * Return a list of all bans.
      *
-     * @return stdClass
+     * @return stdClass|array|bool
      * @throws Exception
      */
-    public function getAll(): stdClass
+    public function getAll(): stdClass|array|bool
     {
         $response = $this->connection->query('server_ban.list');
 
         if (!is_bool($response)) {
-            return $response;
+            return $response->list;
         }
 
         throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
@@ -69,15 +67,14 @@ class ServerBan implements Contracts\ServerBan
     /**
      * Get a specific ban.
      *
-     * @param  array  $params
-     * @return stdClass
+     * @return stdClass|array|bool
      * @throws Exception
      */
-    public function get(array $params): stdClass
+    public function get(string $name, string $type): stdClass|array|bool
     {
         $response = $this->connection->query('server_ban.get', [
-            'name' => $params['name'],
-            'type' => $params['type']
+            'name' => $name,
+            'type' => $type
         ]);
 
         if (!is_bool($response)) {