Completed
Push — master ( d04b6a...4e4c0e )
by Nikolay
03:14
created

EditMessageCaptionMethod   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 16
dl 0
loc 58
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 2
A createInline() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Exception\BadArgumentException;
8
use TgBotApi\BotApiBase\Method\Interfaces\EditMethodAliasInterface;
9
use TgBotApi\BotApiBase\Method\Interfaces\HasParseModeVariableInterface;
10
use TgBotApi\BotApiBase\Method\Traits\EditMessageVariablesTrait;
11
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
12
13
/**
14
 * Class EditMessageCaptionMethod.
15
 *
16
 * @see https://core.telegram.org/bots/api#editmessagecaption
17
 */
18
class EditMessageCaptionMethod implements HasParseModeVariableInterface, EditMethodAliasInterface
19
{
20
    use FillFromArrayTrait;
21
    use EditMessageVariablesTrait;
22
23
    /**
24
     * Optional. New caption of the message.
25
     *
26
     * @var string|null
27
     */
28
    public $caption;
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 the media caption.
33
     *
34
     * @var string|null
35
     */
36
    public $parseMode;
37
38
    /**
39
     * @param $chatId
40
     * @param int        $messageId
41
     * @param array|null $data
42
     *
43
     * @throws BadArgumentException
44
     *
45
     * @return EditMessageCaptionMethod
46
     */
47 1
    public static function create($chatId, int $messageId, array $data = null): EditMessageCaptionMethod
48
    {
49 1
        $instance = new static();
50 1
        $instance->chatId = $chatId;
51 1
        $instance->messageId = $messageId;
52 1
        if ($data) {
53 1
            $instance->fill($data, ['chatId', 'messageId', 'inlineMessageId']);
54
        }
55
56 1
        return $instance;
57
    }
58
59
    /**
60
     * @param string     $inlineMessageId
61
     * @param array|null $data
62
     *
63
     * @throws BadArgumentException
64
     *
65
     * @return EditMessageCaptionMethod
66
     */
67 1
    public static function createInline(string $inlineMessageId, array $data = null): EditMessageCaptionMethod
68
    {
69 1
        $instance = new static();
70 1
        $instance->inlineMessageId = $inlineMessageId;
71 1
        if ($data) {
72 1
            $instance->fill($data, ['chatId', 'messageId', 'inlineMessageId']);
73
        }
74
75 1
        return $instance;
76
    }
77
}
78