GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

DiscordMessage   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 14
c 2
b 1
f 0
dl 0
loc 88
ccs 15
cts 15
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A create() 0 3 1
A body() 0 5 1
A embed() 0 5 1
A components() 0 5 1
1
<?php
2
3
namespace NotificationChannels\Discord;
4
5
class DiscordMessage
6
{
7
    /**
8
     * The text content of the message.
9
     *
10
     * @var string
11
     */
12
    public $body;
13
14
    /**
15
     * The embedded object attached to the message.
16
     *
17
     * @var array
18
     */
19
    public $embed;
20
21
    /**
22
     * The component objects attached to the message.
23
     *
24
     * @var array
25
     */
26
    public $components;
27
28
    /**
29
     * @param string     $body
30
     * @param array|null $embed
31
     *
32
     * @return static
33
     */
34 1
    public static function create($body = '', $embed = [], $components = [])
35
    {
36 1
        return new static($body, $embed, $components);
37
    }
38
39
    /**
40
     * @param string $body
41
     * @param array  $embed
42
     */
43 4
    public function __construct($body = '', $embed = [], $components = [])
44
    {
45 4
        $this->body = $body;
46 4
        $this->embed = $embed;
47 4
        $this->components = $components;
48
    }
49
50
    /**
51
     * Set the text content of the message.
52
     *
53
     * @param string $body
54
     *
55
     * @return $this
56
     */
57 2
    public function body($body)
58
    {
59 2
        $this->body = $body;
60
61 2
        return $this;
62
    }
63
64
    /**
65
     * Set a single embedded object.
66
     * 
67
     * TODO: Refactor to enable multiple embeds.
68
     * See https://discord.com/developers/docs/resources/channel#create-message
69
     *
70
     * @param array $embed
71
     *
72
     * @return $this
73
     */
74 1
    public function embed($embed)
75
    {
76 1
        $this->embed = $embed;
77
78 1
        return $this;
79
    }
80
81
    /**
82
     * Set the components object.
83
     *
84
     * @param array $components
85
     *
86
     * @return $this
87
     */
88 1
    public function components($components)
89
    {
90 1
        $this->components = $components;
91
92 1
        return $this;
93
    }
94
}
95