Completed
Push — master ( 7d37a2...fea370 )
by Nikolay
06:21
created

SendMessageMethod::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Greenplugin\TelegramBot\Method;
6
7
use Greenplugin\TelegramBot\Method\Interfaces\HasParseModeVariableInterface;
8
use Greenplugin\TelegramBot\Method\Traits\FillFromArrayTrait;
9
use Greenplugin\TelegramBot\Method\Traits\SendToChatVariablesTrait;
10
11
/**
12
 * Class SendMessageMethod.
13
 *
14
 * @see https://core.telegram.org/bots/api#sendmessage
15
 */
16
class SendMessageMethod implements HasParseModeVariableInterface
17
{
18
    use FillFromArrayTrait;
19
    use SendToChatVariablesTrait;
20
21
    /**
22
     * Text of the message to be sent.
23
     *
24
     * @var string
25
     */
26
    public $text;
27
28
    /**
29
     * Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width
30
     * text or inline URLs in the media caption.
31
     *
32
     * @var string|null
33
     */
34
    public $parseMode;
35
36
    /**
37
     * Optional. Disables link previews for links in this message.
38
     *
39
     * @var bool|null
40
     */
41
    public $disableWebPagePreview;
42
43
    /**
44
     * SendMessageMethod constructor.
45
     *
46
     * @param int|string $chatId
47
     * @param string     $text
48
     * @param array|null $data
49
     *
50
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
51
     */
52 6
    public function __construct($chatId, string $text, array $data = null)
53
    {
54 6
        $this->chatId = $chatId;
55 6
        $this->text = $text;
56 6
        if ($data) {
57 3
            $this->fill($data);
58
        }
59 6
    }
60
}
61