]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blobdiff - lib/Ban.php
Merge pull request #5 from unrealircd/wip
[irc/unrealircd/unrealircd-rpc-php.git] / lib / Ban.php
index 1b90e724017c7e81fc1e1b256e0a658460171914..2a2272caeb4254a99f511e3f4e17a8606720657f 100644 (file)
@@ -16,6 +16,8 @@ class Ban implements Contracts\Ban
     }
 
     /**
+     * Add a ban.
+     *
      * @param  string  $user
      * @param  array  $params
      * @return stdClass
@@ -23,21 +25,17 @@ 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'],
-            'length' => $params['length'] ?? '1d',
+            'duration_string' => $params['length'] ?? '1d',
         ]);
-
-        if (is_bool($response)) {
-            return $response;
-        }
-
-        throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
     }
 
     /**
+     * Delete a ban.
+     *
      * @param  string  $user
      * @param  array  $params
      * @return stdClass
@@ -45,20 +43,16 @@ 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'],
         ]);
-
-        if (is_bool($response)) {
-            return $response;
-        }
-
-        throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
     }
 
     /**
-     * @return array|bool
+     * Return a list of all bans.
+     *
+     * @return stdClass
      * @throws Exception
      */
     public function get(): stdClass
@@ -73,8 +67,10 @@ class Ban implements Contracts\Ban
     }
 
     /**
+     * Show a specific ban.
+     *
      * @param  array  $params
-     * @return object|bool
+     * @return stdClass
      * @throws Exception
      */
     public function show(array $params): stdClass