Completed
Push — master ( 442409...8731fa )
by Gideon
21s queued 12s
created
src/Gidkom/OpenFireRestApi/OpenFireRestApi.php 4 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,9 @@
 block discarded – undo
25 25
     {
26 26
         $query = '';
27 27
         
28
-        if(isset($opts['search'])) $query .= '?search='.$opts['search'];
28
+        if(isset($opts['search'])) {
29
+            $query .= '?search='.$opts['search'];
30
+        }
29 31
         
30 32
     	$endpoint = '/users'.$query;        
31 33
     	return $this->doRequest('GET', $endpoint);
Please login to merge, or discard this patch.
Doc Comments   -8 removed lines patch added patch discarded remove patch
@@ -119,7 +119,6 @@  discard block
 block discarded – undo
119 119
      * Add user to a group
120 120
      *
121 121
      * @param   string          $username   Username
122
-     * @param   string           $groups   Groups to add user
123 122
      * @return  json|false                 Json with data or error, or False when something went fully wrong
124 123
      */
125 124
     public function addToGroup($username, $groupName)
@@ -133,7 +132,6 @@  discard block
 block discarded – undo
133 132
      * Delete user from a group
134 133
      *
135 134
      * @param   string          $username   Username
136
-     * @param   string           $groups   Groups to add user
137 135
      * @return  json|false                 Json with data or error, or False when something went fully wrong
138 136
      */
139 137
     public function deleteFromGroup($username, $groupName)
@@ -277,7 +275,6 @@  discard block
 block discarded – undo
277 275
     /**
278 276
      * Delete a chat room
279 277
      *
280
-     * @param   string      $name               Name of the Group to delete
281 278
      * @return  json|false                       Json with data or error, or False when something went fully wrong
282 279
      */
283 280
     public function deleteChatRoom($roomName)
@@ -288,7 +285,6 @@  discard block
 block discarded – undo
288 285
     /**
289 286
      * Get chat room participants
290 287
      *
291
-     * @param   string      $name               Name of the chatroom
292 288
      * @return  json|false                       Json with data or error, or False when something went fully wrong
293 289
      */
294 290
     public function getChatRoomParticipants($roomName)      
@@ -299,7 +295,6 @@  discard block
 block discarded – undo
299 295
     /**
300 296
      * Get chat room occupants
301 297
      *
302
-     * @param   string      $name               Name of the chatroom
303 298
      * @return  json|false                       Json with data or error, or False when something went fully wrong
304 299
      */
305 300
     public function getChatRoomOccupants($roomName)      
@@ -356,7 +351,6 @@  discard block
 block discarded – undo
356 351
     /**
357 352
      * Retrieve a system property
358 353
      *
359
-     * @param   string      $name                Name of property
360 354
      * @return  json|false                       Json with data or error, or False when something went fully wrong
361 355
      */
362 356
     public function getSystemProperty($propertyName)
@@ -393,7 +387,6 @@  discard block
 block discarded – undo
393 387
     /**
394 388
      * Delete a system property
395 389
      *
396
-     * @param   array      $data                new property with value
397 390
      * @return  json|false                       Json with data or error, or False when something went fully wrong
398 391
      */
399 392
     public function deleteSystemProperty($propertyName)
@@ -514,7 +507,6 @@  discard block
 block discarded – undo
514 507
     /**
515 508
      * Send a broadcast message to all online users
516 509
      *
517
-     * @param  string      $content               message to send
518 510
      * @return json|false       Json with data or error, or False when something went fully wrong
519 511
      */
520 512
     public function broadcastMessage($message = '')
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
         
28 28
         if(isset($opts['search'])) $query .= '?search='.$opts['search'];
29 29
         
30
-    	$endpoint = '/users'.$query;        
31
-    	return $this->doRequest('GET', $endpoint);
30
+        $endpoint = '/users'.$query;        
31
+        return $this->doRequest('GET', $endpoint);
32 32
     }
33 33
 
34 34
 
@@ -413,11 +413,11 @@  discard block
 block discarded – undo
413 413
     }
414 414
 
415 415
 
416
-     /**
417
-     * Get all groups
418
-     *
419
-     * @return  json|false      Json with data or error, or False when something went fully wrong
420
-     */
416
+        /**
417
+         * Get all groups
418
+         *
419
+         * @return  json|false      Json with data or error, or False when something went fully wrong
420
+         */
421 421
     public function getGroups()
422 422
     {
423 423
         $endpoint = '/groups';
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
      *
22 22
      * @return json|false       Json with data or error, or False when something went fully wrong
23 23
      */
24
-    public function getUsers($opts = [])
24
+    public function getUsers($opts = [ ])
25 25
     {
26 26
         $query = '';
27 27
         
28
-        if(isset($opts['search'])) $query .= '?search='.$opts['search'];
28
+        if (isset($opts[ 'search' ])) $query .= '?search='.$opts[ 'search' ];
29 29
         
30 30
     	$endpoint = '/users'.$query;        
31 31
     	return $this->doRequest('GET', $endpoint);
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
      * @param   string|false    $email      Email   (Optional)
54 54
      * @return  json|false                 Json with data or error, or False when something went fully wrong
55 55
      */
56
-    public function addUser($username, $password, $name=false, $email=false)
56
+    public function addUser($username, $password, $name = false, $email = false)
57 57
     {
58 58
         $endpoint = '/users'; 
59
-        return $this->doRequest('POST', $endpoint, compact('username', 'password','name','email'));
59
+        return $this->doRequest('POST', $endpoint, compact('username', 'password', 'name', 'email'));
60 60
     }
61 61
 
62 62
 
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
      * @param   string[]|false  $groups     Groups (Optional)
83 83
      * @return  json|false                 Json with data or error, or False when something went fully wrong
84 84
      */
85
-    public function updateUser($username, $password, $name=false, $email=false, $groups=false)
85
+    public function updateUser($username, $password, $name = false, $email = false, $groups = false)
86 86
     {
87 87
         $endpoint = '/users/'.$username; 
88
-        return $this->doRequest('PUT', $endpoint, compact('username', 'password','name','email', 'groups'));
88
+        return $this->doRequest('PUT', $endpoint, compact('username', 'password', 'name', 'email', 'groups'));
89 89
     }
90 90
 
91 91
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     public function addToGroup($username, $groupName)
125 125
     {
126 126
         $endpoint = '/users/'.$username.'/groups/'.$groupName; 
127
-        return $this->doRequest('POST', $endpoint );
127
+        return $this->doRequest('POST', $endpoint);
128 128
     }
129 129
 
130 130
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     public function deleteFromGroup($username, $groupName)
139 139
     {
140 140
         $endpoint = '/users/'.$username.'/groups/'.$groupName; 
141
-        return $this->doRequest('DELETE', $endpoint );
141
+        return $this->doRequest('DELETE', $endpoint);
142 142
     }
143 143
 
144 144
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
     public function userRosters($username)
178 178
     {
179 179
         $endpoint = '/users/'.$username.'/roster';
180
-        return $this->doRequest('GET', $endpoint, compact('jid','name','subscriptionType'));
180
+        return $this->doRequest('GET', $endpoint, compact('jid', 'name', 'subscriptionType'));
181 181
     }
182 182
 
183 183
 
@@ -190,10 +190,10 @@  discard block
 block discarded – undo
190 190
      * @param   int|false       $subscriptionType   	Subscription (Optional)
191 191
      * @return  json|false                     		Json with data or error, or False when something went fully wrong
192 192
      */
193
-    public function addToRoster($username, $jid, $name=false, $subscriptionType=false)
193
+    public function addToRoster($username, $jid, $name = false, $subscriptionType = false)
194 194
     {
195 195
         $endpoint = '/users/'.$username.'/roster';
196
-        return $this->doRequest('POST', $endpoint, compact('jid','name','subscriptionType'));
196
+        return $this->doRequest('POST', $endpoint, compact('jid', 'name', 'subscriptionType'));
197 197
     }
198 198
 
199 199
 
@@ -219,10 +219,10 @@  discard block
 block discarded – undo
219 219
      * @param   int|false       $subscriptionType   Subscription (Optional)
220 220
      * @return  json|false                          Json with data or error, or False when something went fully wrong
221 221
      */
222
-    public function updateRoster($username, $jid, $nickname=false, $subscriptionType=false)
222
+    public function updateRoster($username, $jid, $nickname = false, $subscriptionType = false)
223 223
     {
224 224
         $endpoint = '/users/'.$username.'/roster/'.$jid;
225
-        return $this->doRequest('PUT', $endpoint, $jid, compact('jid','username','subscriptionType'));     
225
+        return $this->doRequest('PUT', $endpoint, $jid, compact('jid', 'username', 'subscriptionType'));     
226 226
     }
227 227
 
228 228
    
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
      * @param   string          $params        Params
256 256
      * @return  json|false                     Json with data or error, or False when something went fully wrong
257 257
      */
258
-    public function createChatRoom($params = [])
258
+    public function createChatRoom($params = [ ])
259 259
     {
260 260
         return $this->doRequest('POST', '/chatrooms', $params);
261 261
     }
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
      * @param   string          $params        Params
268 268
      * @return  json|false                     Json with data or error, or False when something went fully wrong
269 269
      */
270
-    public function updateChatRoom($roomName, $params = [])
270
+    public function updateChatRoom($roomName, $params = [ ])
271 271
     {
272 272
         return $this->doRequest('PUT', '/chatrooms/'.$roomName, $params);
273 273
     }
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
     public function createGroup($name, $description = false)
447 447
     {
448 448
         $endpoint = '/groups/';
449
-        return $this->doRequest('POST', $endpoint, compact('name','description'));
449
+        return $this->doRequest('POST', $endpoint, compact('name', 'description'));
450 450
     }
451 451
 
452 452
     /**
@@ -468,10 +468,10 @@  discard block
 block discarded – undo
468 468
      * @param   string      $description        Some description of the group
469 469
      *
470 470
      */
471
-    public function updateGroup($name,  $description)
471
+    public function updateGroup($name, $description)
472 472
     {
473 473
         $endpoint = '/groups/'.$name;
474
-        return $this->doRequest('PUT', $endpoint, compact('name','description'));
474
+        return $this->doRequest('PUT', $endpoint, compact('name', 'description'));
475 475
     }
476 476
 
477 477
 
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
      */
519 519
     public function broadcastMessage($message = '')
520 520
     {
521
-        $content =['body'=> $message];
521
+        $content = [ 'body'=> $message ];
522 522
         $endpoint = '/messages/users';
523 523
         return $this->doRequest('POST', $endpoint, $content);
524 524
     }
Please login to merge, or discard this patch.
src/Gidkom/OpenFireRestApi/RestClient.php 3 patches
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -45,10 +45,11 @@
 block discarded – undo
45 45
     	$base = ($this->useSSL) ? "https" : "http";
46 46
     	$url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint;
47 47
 	    
48
-		if ($this->useBasicAuth)
49
-            $auth = 'Basic ' . base64_encode($this->basicUser . ':' . $this->basicPwd);
50
-        else
51
-            $auth = $this->secret;
48
+		if ($this->useBasicAuth) {
49
+		            $auth = 'Basic ' . base64_encode($this->basicUser . ':' . $this->basicPwd);
50
+		} else {
51
+                    $auth = $this->secret;
52
+        }
52 53
 	    
53 54
     	$headers = array(
54 55
   			'Accept' => 'application/json',
Please login to merge, or discard this patch.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 */
9 9
 class RestClient
10 10
 {
11
-	public $host = 'localhost';
11
+    public $host = 'localhost';
12 12
     public $port = '9090';
13 13
     public $plugin = '/plugins/restapi/v1';
14 14
     public $secret = 'SuperSecret';
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
     public $basicUser = 'admin';
21 21
     public $basicPwd = '1234';
22 22
 
23
-	function __construct()
24
-	{
25
-		$this->client = new Client();
26
-	}
23
+    function __construct()
24
+    {
25
+        $this->client = new Client();
26
+    }
27 27
 
28 28
     /**
29 29
      * Make the request and analyze the result
@@ -33,28 +33,28 @@  discard block
 block discarded – undo
33 33
      * @param   array           $params         Parameters
34 34
      * @return  array|false                     Array with data or error, or False when something went fully wrong
35 35
      */
36
-	protected function doRequest($type, $endpoint, $params=[])
36
+    protected function doRequest($type, $endpoint, $params=[])
37 37
     {
38
-    	$base = ($this->useSSL) ? "https" : "http";
39
-    	$url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint;
38
+        $base = ($this->useSSL) ? "https" : "http";
39
+        $url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint;
40 40
 	    
41
-		if ($this->useBasicAuth)
41
+        if ($this->useBasicAuth)
42 42
             $auth = 'Basic ' . base64_encode($this->basicUser . ':' . $this->basicPwd);
43 43
         else
44 44
             $auth = $this->secret;
45 45
 	    
46
-    	$headers = array(
47
-  			'Accept' => 'application/json',
48
-  			'Authorization' => $auth,
46
+        $headers = array(
47
+                'Accept' => 'application/json',
48
+                'Authorization' => $auth,
49 49
             'Content-Type'=>'application/json'
50
-  		);
50
+            );
51 51
 
52 52
         $body = json_encode($params);
53 53
 
54 54
         try {
55
-        	$result = $this->client->request($type, $url, compact('headers','body'));
55
+            $result = $this->client->request($type, $url, compact('headers','body'));
56 56
         } catch (\Exception $e) {
57
-        	return  ['status'=>false, 'data'=>['message'=>$e->getMessage()]];
57
+            return  ['status'=>false, 'data'=>['message'=>$e->getMessage()]];
58 58
         }
59 59
 	        
60 60
         
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
      * @param   array           $params         Parameters
34 34
      * @return  array|false                     Array with data or error, or False when something went fully wrong
35 35
      */
36
-	protected function doRequest($type, $endpoint, $params=[])
36
+	protected function doRequest($type, $endpoint, $params = [ ])
37 37
     {
38 38
     	$base = ($this->useSSL) ? "https" : "http";
39
-    	$url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint;
39
+    	$url = $base."://".$this->host.":".$this->port.$this->plugin.$endpoint;
40 40
 	    
41 41
 		if ($this->useBasicAuth)
42
-            $auth = 'Basic ' . base64_encode($this->basicUser . ':' . $this->basicPwd);
42
+            $auth = 'Basic '.base64_encode($this->basicUser.':'.$this->basicPwd);
43 43
         else
44 44
             $auth = $this->secret;
45 45
 	    
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
         $body = json_encode($params);
53 53
 
54 54
         try {
55
-        	$result = $this->client->request($type, $url, compact('headers','body'));
55
+        	$result = $this->client->request($type, $url, compact('headers', 'body'));
56 56
         } catch (\Exception $e) {
57
-        	return  ['status'=>false, 'data'=>['message'=>$e->getMessage()]];
57
+        	return  [ 'status'=>false, 'data'=>[ 'message'=>$e->getMessage() ] ];
58 58
         }
59 59
 	        
60 60
         
Please login to merge, or discard this patch.