Completed
Push — master ( fafdd5...fa6b31 )
by Cody
37:25
created

src/DiscordMessage.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
     * @param string     $body
23
     * @param array|null $embed
24
     *
25
     * @return static
26
     */
27
    public static function create($body = '', $embed = [])
28
    {
29
        return new static($body, $embed);
0 ignored issues
show
It seems like $embed defined by parameter $embed on line 27 can also be of type null; however, NotificationChannels\Dis...dMessage::__construct() does only seem to accept array, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
30
    }
31
32
    /**
33
     * @param string $body
34
     * @param array  $embed
35
     */
36
    public function __construct($body = '', $embed = [])
37
    {
38
        $this->body = $body;
39
        $this->embed = $embed;
40
    }
41
42
    /**
43
     * Set the text content of the message.
44
     *
45
     * @param string $body
46
     *
47
     * @return $this
48
     */
49
    public function body($body)
50
    {
51
        $this->body = $body;
52
53
        return $this;
54
    }
55
56
    /**
57
     * Set the embedded object.
58
     *
59
     * @param $embed
60
     *
61
     * @return $this
62
     */
63
    public function embed($embed)
64
    {
65
        $this->embed = $embed;
66
67
        return $this;
68
    }
69
}
70