Completed
Push — master ( 5d5473...3f41e3 )
by Luca
02:37
created

SessionEndpoint   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 38
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A retrieveAllUserSession() 0 4 1
A retrieveUserSessions() 0 5 1
A closeAllUserSessions() 0 5 1
1
<?php
2
/**
3
 * OpenFireRestAPI is based entirely on official documentation of the REST API
4
 * Plugin and you can extend it by following the directives of the documentation
5
 *
6
 * For the full copyright and license information, please read the LICENSE
7
 * file that was distributed with this source code. For the full list of
8
 * contributors, visit https://github.com/gnello/PHPOpenFireRestAPI/contributors
9
 *
10
 * @author Luca Agnello <[email protected]>
11
 * @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html
12
 */
13
14
namespace Gnello\OpenFireRestAPI\Endpoints;
15
16
use \Gnello\OpenFireRestAPI\Dispatcher\Method;
17
use \Gnello\OpenFireRestAPI\Dispatcher\Dispatcher;
18
19
/**
20
 * Session related REST Endpoint
21
 * Class SessionEndpoint
22
 * @package Gnello\OpenFireRestAPI\Endpoints
23
 * @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#session-related-rest-endpoints
24
 */
25
class SessionEndpoint extends Dispatcher
26
{
27
    public static $endpoint = '/sessions';
28
29
    /**
30
     * Get all user sessions
31
     * @return array with Sessions
32
     * @link http://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#retrieve-all-user-session
33
     */
34
    public static function retrieveAllUserSession()
35
    {
36
        return self::sendRequest(Method::GET, self::$endpoint);
37
    }
38
39
    /**
40
     * Get sessions from a user
41
     * @param $username
42
     * @return array with Sessions
43
     * @link http://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#retrieve-the-user-sessions
44
     */
45
    public static function retrieveUserSessions($username)
46
    {
47
        $endpoint = self::$endpoint . '/' . $username;
48
        return self::sendRequest(Method::GET, $endpoint);
49
    }
50
51
    /**
52
     * Close/kick sessions from a user
53
     * @param $username
54
     * @return array with HTTP status 200 (OK)
55
     * @link http://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#close-all-user-sessions
56
     */
57
    public static function closeAllUserSessions($username)
58
    {
59
        $endpoint = self::$endpoint . '/' . $username;
60
        return self::sendRequest(Method::DELETE, $endpoint);
61
    }
62
}