EditMessageCaptionMethod::createInline()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 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