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

MessageEndpoint   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A sendBroadcastMessage() 0 6 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
use \Gnello\OpenFireRestAPI\Payloads;
19
20
/**
21
 * Message related REST Endpoint
22
 * Class MessageEndpoint
23
 * @package Gnello\OpenFireRestAPI\Endpoints
24
 * @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#message-related-rest-endpoints
25
 */
26
class MessageEndpoint extends Dispatcher
27
{
28
    public static $endpoint = '/messages';
29
30
    /**
31
     * Send a broadcast/server message to all online users
32
     * @param $body
33
     * @return array with HTTP status 201 (Created)
34
     * @link http://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#send-a-broadcast-message
35
     */
36
    public static function sendBroadcastMessage($body)
37
    {
38
        $payload = new Payloads\MessagePayload(compact('body'));
39
        $endpoint = self::$endpoint . UserEndpoint::$endpoint;
40
        return self::sendRequest(Method::POST, $endpoint, $payload);
41
    }
42
}