ReactionsAddPayload::setFileComment()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
namespace PortlandLabs\Slackbot\Slack\Api\Payload;
3
4
use CL\Slack\Payload\AbstractPayload;
5
use PortlandLabs\Slackbot\Slack\Rtm\Event\Message;
6
7
class ReactionsAddPayload extends AbstractPayload
8
{
9
10
    /** @var string */
11
    protected $name;
12
13
    /** @var string */
14
    protected $channel;
15
16
    /** @var string */
17
    protected $file;
18
19
    /** @var string */
20
    protected $fileComment;
21
22
    /** @var string */
23
    protected $timestamp;
24
25
    /**
26
     * @return string
27
     */
28
    public function getMethod()
29
    {
30
        return 'reactions.add';
31
    }
32
33
    /**
34
     * @return string
35
     */
36
    public function getName(): string
37
    {
38
        return $this->name;
39
    }
40
41
    /**
42
     * @param string $name
43
     */
44
    public function setName(string $name): void
45
    {
46
        $this->name = $name;
47
    }
48
49
    /**
50
     * @return string
51
     */
52
    public function getChannel(): string
53
    {
54
        return $this->channel;
55
    }
56
57
    /**
58
     * @param string $channel
59
     */
60
    public function setChannel(string $channel): void
61
    {
62
        $this->channel = $channel;
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function getFile(): string
69
    {
70
        return $this->file;
71
    }
72
73
    /**
74
     * @param string $file
75
     */
76
    public function setFile(string $file): void
77
    {
78
        $this->file = $file;
79
    }
80
81
    /**
82
     * @return string
83
     */
84
    public function getFileComment(): string
85
    {
86
        return $this->fileComment;
87
    }
88
89
    /**
90
     * @param string $fileComment
91
     */
92
    public function setFileComment(string $fileComment): void
93
    {
94
        $this->fileComment = $fileComment;
95
    }
96
97
    /**
98
     * @return string
99
     */
100
    public function getTimestamp(): string
101
    {
102
        return $this->timestamp;
103
    }
104
105
    /**
106
     * @param string $timestamp
107
     */
108
    public function setTimestamp(string $timestamp): void
109
    {
110
        $this->timestamp = $timestamp;
111
    }
112
113
    /**
114
     * React to a message
115
     *
116
     * @param Message $message
117
     *
118
     * @return ReactionsAddPayload
119
     */
120
    public static function reactTo(Message $message, string $reaction): ReactionsAddPayload
121
    {
122
        $self = new self();
123
124
        $self->setTimestamp($message->getTimestamp());
125
        $self->setChannel($message->getChannel());
0 ignored issues
show
Bug introduced by
It seems like $message->getChannel() can also be of type null; however, parameter $channel of PortlandLabs\Slackbot\Sl...ddPayload::setChannel() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

125
        $self->setChannel(/** @scrutinizer ignore-type */ $message->getChannel());
Loading history...
126
127
        $self->setName($reaction);
128
129
        return $self;
130
    }
131
132
}