SendsMessages   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 11
dl 0
loc 32
rs 10
c 0
b 0
f 0
ccs 11
cts 11
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A reply() 0 7 1
A sendAttachment() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Conversation\Concerns;
6
7
use FondBot\Drivers\PendingReply;
8
use FondBot\Templates\Attachment;
9
10
trait SendsMessages
11
{
12
    /**
13
     * Send reply to user.
14
     *
15
     * @param string|null $text
16
     *
17
     * @return PendingReply
18
     */
19
    protected function reply(string $text = null): PendingReply
20 3
    {
21
        return (new PendingReply(
22 3
            context()->getChannel(),
23 3
            context()->getChat(),
24 3
            context()->getUser()
25 3
        ))->text($text);
26 3
    }
27
28
    /**
29
     * Send attachment to user.
30
     *
31
     * @param Attachment $attachment
32
     *
33
     * @return PendingReply
34
     */
35
    protected function sendAttachment(Attachment $attachment): PendingReply
36 2
    {
37
        return (new PendingReply(
38 2
            context()->getChannel(),
39 2
            context()->getChat(),
40 2
            context()->getUser()
41 2
        ))->attachment($attachment);
42 2
    }
43
}
44