Passed
Push — draft ( 8ec7b9...aebf0a )
by Nikolay
03:09
created

SendMessageMethod   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 46
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 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
     * @param int|string $chatId
45
     * @param string     $text
46
     * @param array|null $data
47
     *
48
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
49
     *
50
     * @return SendMessageMethod
51
     */
52 1
    public static function create($chatId, string $text, array $data = null): SendMessageMethod
53
    {
54 1
        $instance = new static();
55 1
        $instance->chatId = $chatId;
56 1
        $instance->text = $text;
57 1
        if ($data) {
58 1
            $instance->fill($data);
59
        }
60
61 1
        return $instance;
62
    }
63
}
64