Completed
Push — master ( fa98ea...c23364 )
by Luca
02:32
created

API::Payloads()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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;
15
16
/**
17
 * API manager
18
 * Class API
19
 * @package Gnello\OpenFireRestAPI
20
 * @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html
21
 */
22
class API
23
{
24
    /**
25
     * @var Settings\Settings
26
     */
27
    private $settings;
28
29
    /**
30
     * @var Endpoints\UserEndpoint
31
     */
32
    private $users;
33
34
    /**
35
     * @var Endpoints\ChatRoomEndpoint
36
     */
37
    private $chatrooms;
38
39
    /**
40
     * @var Endpoints\GroupEndpoint
41
     */
42
    private $groups;
43
44
    /**
45
     * @var Endpoints\MessageEndpoint
46
     */
47
    private $messages;
48
49
    /**
50
     * @var Endpoints\SessionEndpoint
51
     */
52
    private $sessions;
53
54
    /**
55
     * @var Endpoints\SystemEndpoint
56
     */
57
    private $system;
58
59
    /**
60
     * @var Payloads\Payload
61
     */
62
    private $payloads;
63
64
    /**
65
     * @var Utils\Debugger
66
     */
67
    private $debugger;
68
69
    /**
70
     * API constructor.
71
     * @param                     $host
72
     * @param                     $port
73
     * @param AuthenticationToken $authenticationToken
74
     */
75
    public function __construct($host, $port, AuthenticationToken $authenticationToken)
76
    {
77
        $settings = Settings\Settings::getInstance();
78
        $settings->setHost($host);
79
        $settings->setPort($port);
80
        $settings->setServerNameFromHost($host);
81
        $settings->setAuthenticationToken($authenticationToken);
82
83
        $this->settings     = $settings;
84
        $this->users        = new Endpoints\UserEndpoint();
85
        $this->chatrooms    = new Endpoints\ChatRoomEndpoint();
86
        $this->groups       = new Endpoints\GroupEndpoint();
87
        $this->messages     = new Endpoints\MessageEndpoint();
88
        $this->sessions     = new Endpoints\SessionEndpoint();
89
        $this->system       = new Endpoints\SystemEndpoint();
90
        $this->payloads     = new Payloads\Payload();
91
        $this->debugger     = Utils\Debugger::getInstance();
92
    }
93
94
    /**
95
     * @return Settings\Settings
96
     */
97
    public function Settings()
98
    {
99
        return $this->settings;
100
    }
101
102
    /**
103
     * @return Endpoints\UserEndpoint
104
     */
105
    public function Users()
106
    {
107
        return $this->users;
108
    }
109
110
    /**
111
     * @return Endpoints\ChatRoomEndpoint
112
     */
113
    public function ChatRooms()
114
    {
115
        return $this->chatrooms;
116
    }
117
118
    /**
119
     * @return Endpoints\GroupEndpoint
120
     */
121
    public function Groups()
122
    {
123
        return $this->groups;
124
    }
125
126
    /**
127
     * @return Endpoints\MessageEndpoint
128
     */
129
    public function Messages()
130
    {
131
        return $this->messages;
132
    }
133
134
    /**
135
     * @return Endpoints\SessionEndpoint
136
     */
137
    public function Sessions()
138
    {
139
        return $this->sessions;
140
    }
141
142
    /**
143
     * @return Endpoints\SystemEndpoint
144
     */
145
    public function System()
146
    {
147
        return $this->system;
148
    }
149
150
    /**
151
     * @return Payloads\Payload
152
     */
153
    public function Payloads()
154
    {
155
        return $this->payloads;
156
    }
157
158
    /**
159
     * @return Utils\Debugger
160
     */
161
    public function Debugger()
162
    {
163
        return $this->debugger;
164
    }
165
}