Passed
Push — master ( c05883...1d5c29 )
by Nikolay
02:30
created

EditMessageTextMethod::createInline()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 13
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\HasParseModeVariableInterface;
8
use TgBotApi\BotApiBase\Method\Traits\EditMessageVariablesTrait;
9
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
10
11
/**
12
 * Class EditMessageTextMethod.
13
 *
14
 * @see https://core.telegram.org/bots/api#editmessagetext
15
 */
16
class EditMessageTextMethod implements HasParseModeVariableInterface
17
{
18
    use FillFromArrayTrait;
19
    use EditMessageVariablesTrait;
20
21
    /**
22
     * New text of the message.
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,
30
     * fixed-width text or inline URLs in your bot's message.
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 int        $messageId
46
     * @param string     $text
47
     * @param array|null $data
48
     *
49
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
50
     *
51
     * @return EditMessageTextMethod
52
     */
53
    public static function create($chatId, int $messageId, string $text, array $data = null): EditMessageTextMethod
54
    {
55
        $instance = new self();
56
        $instance->chatId = $chatId;
57
        $instance->text = $text;
58
        $instance->messageId = $messageId;
59
        if ($data) {
60
            $instance->fill($data);
61
        }
62
63
        return $instance;
64
    }
65
66
    /**
67
     * @param string     $inlineMessageId
68
     * @param string     $text
69
     * @param array|null $data
70
     *
71
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
72
     *
73
     * @return EditMessageTextMethod
74
     */
75
    public static function createInline(
76
        string $inlineMessageId,
77
        string $text,
78
        array $data = null
79
    ): EditMessageTextMethod {
80
        $instance = new self();
81
        $instance->inlineMessageId = $inlineMessageId;
82
        $instance->text = $text;
83
        if ($data) {
84
            $instance->fill($data);
85
        }
86
87
        return $instance;
88
    }
89
}
90