]> 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 4cffb818ecce1803e9282ed581f74e8db8944cfa..2a2272caeb4254a99f511e3f4e17a8606720657f 100644 (file)
@@ -16,51 +16,43 @@ class Ban implements Contracts\Ban
     }
 
     /**
+     * Add a ban.
+     *
      * @param  string  $user
-     * @param  string  $type
      * @param  array  $params
      * @return stdClass
      * @throws Exception
      */
-    public function add(string $user, string $type, array $params): stdClass
+    public function add(string $user, array $params): stdClass
     {
-        $response = $this->connection->query('server_ban.add', [
-            'name' => $params['name'],
+        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  string  $type
      * @param  array  $params
      * @return stdClass
      * @throws Exception
      */
-    public function delete(string $user, string $type, array $params): stdClass
+    public function delete(string $user, array $params): stdClass
     {
-        $response = $this->connection->query('server_ban.del', [
-            'name' => $params['name'],
+        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
@@ -75,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