EditMessageTextMethod   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 20
dl 0
loc 68
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createInline() 0 13 2
A create() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\EditMethodAliasInterface;
8
use TgBotApi\BotApiBase\Method\Interfaces\HasParseModeVariableInterface;
9
use TgBotApi\BotApiBase\Method\Traits\EditMessageVariablesTrait;
10
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
11
use TgBotApi\BotApiBase\Type\MessageEntityType;
12
13
/**
14
 * Class EditMessageTextMethod.
15
 *
16
 * @see https://core.telegram.org/bots/api#editmessagetext
17
 */
18
class EditMessageTextMethod implements HasParseModeVariableInterface, EditMethodAliasInterface
19
{
20
    use FillFromArrayTrait;
21
    use EditMessageVariablesTrait;
22
23
    /**
24
     * New text of the message.
25
     *
26
     * @var string
27
     */
28
    public $text;
29
30
    /**
31
     * Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic,
32
     * fixed-width text or inline URLs in your bot's message.
33
     *
34
     * @var string|null
35
     */
36
    public $parseMode;
37
38
    /**
39
     * Optional. List of special entities that appear in message text, which can be specified instead of parse_mode.
40
     *
41
     * @var MessageEntityType[]|null
42
     */
43
    public $entities;
44
45
    /**
46
     * Optional. Disables link previews for links in this message.
47
     *
48
     * @var bool|null
49
     */
50
    public $disableWebPagePreview;
51
52
    /**
53
     * @param int|string $chatId
54
     *
55
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
56
     */
57 1
    public static function create($chatId, int $messageId, string $text, array $data = null): EditMessageTextMethod
58
    {
59 1
        $instance = new self();
60 1
        $instance->chatId = $chatId;
61 1
        $instance->text = $text;
62 1
        $instance->messageId = $messageId;
63 1
        if ($data) {
64 1
            $instance->fill($data);
65
        }
66
67 1
        return $instance;
68
    }
69
70
    /**
71
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
72
     */
73 1
    public static function createInline(
74
        string $inlineMessageId,
75
        string $text,
76
        array $data = null
77
    ): EditMessageTextMethod {
78 1
        $instance = new self();
79 1
        $instance->inlineMessageId = $inlineMessageId;
80 1
        $instance->text = $text;
81 1
        if ($data) {
82 1
            $instance->fill($data);
83
        }
84
85 1
        return $instance;
86
    }
87
}
88