Passed
Push — master ( 30520d...33f18a )
by Vladimir
03:04
created

SendsMessages::sendRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 7
c 0
b 0
f 0
ccs 6
cts 6
cp 1
rs 10
cc 1
nc 1
nop 2
crap 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