EditMessageCaptionMethod   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 15
dl 0
loc 35
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\CaptionVariablesTrait;
11
use TgBotApi\BotApiBase\Method\Traits\EditMessageVariablesTrait;
12
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
13
14
/**
15
 * Use this method to edit captions of messages. On success, if the edited message is not an inline message,
16
 * the edited Message is returned, otherwise True is returned.
17
 *
18
 * @see https://core.telegram.org/bots/api#editmessagecaption
19
 */
20
class EditMessageCaptionMethod implements HasParseModeVariableInterface, EditMethodAliasInterface
21
{
22
    use FillFromArrayTrait;
23
    use EditMessageVariablesTrait;
24
    use CaptionVariablesTrait;
25
26
    /**
27
     * @param $chatId
28
     *
29
     * @throws BadArgumentException
30
     */
31 1
    public static function create($chatId, int $messageId, array $data = null): EditMessageCaptionMethod
32
    {
33 1
        $instance = new static();
34 1
        $instance->chatId = $chatId;
35 1
        $instance->messageId = $messageId;
36 1
        if ($data) {
37 1
            $instance->fill($data, ['chatId', 'messageId', 'inlineMessageId']);
38
        }
39
40 1
        return $instance;
41
    }
42
43
    /**
44
     * @throws BadArgumentException
45
     */
46 1
    public static function createInline(string $inlineMessageId, array $data = null): EditMessageCaptionMethod
47
    {
48 1
        $instance = new static();
49 1
        $instance->inlineMessageId = $inlineMessageId;
50 1
        if ($data) {
51 1
            $instance->fill($data, ['chatId', 'messageId', 'inlineMessageId']);
52
        }
53
54 1
        return $instance;
55
    }
56
}
57