Passed
Push — draft ( 8ec7b9...aebf0a )
by Nikolay
03:09
created

EditMessageCaptionMethod::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Greenplugin\TelegramBot\Method;
6
7
use Greenplugin\TelegramBot\Exception\BadArgumentException;
8
use Greenplugin\TelegramBot\Method\Interfaces\HasParseModeVariableInterface;
9
use Greenplugin\TelegramBot\Method\Traits\EditMessageVariablesTrait;
10
use Greenplugin\TelegramBot\Method\Traits\FillFromArrayTrait;
11
12
/**
13
 * Class EditMessageCaptionMethod.
14
 *
15
 * @see https://core.telegram.org/bots/api#editmessagecaption
16
 */
17
class EditMessageCaptionMethod implements HasParseModeVariableInterface
18
{
19
    use FillFromArrayTrait;
20
    use EditMessageVariablesTrait;
21
22
    /**
23
     * Optional. New caption of the message.
24
     *
25
     * @var string|null
26
     */
27
    public $caption;
28
29
    /**
30
     * Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic,
31
     * fixed-width text or inline URLs in the media caption.
32
     *
33
     * @var string|null
34
     */
35
    public $parseMode;
36
37
    /**
38
     * @param $chatId
39
     * @param int        $messageId
40
     * @param array|null $data
41
     *
42
     * @throws BadArgumentException
43
     *
44
     * @return EditMessageCaptionMethod
45
     */
46
    public static function create($chatId, int $messageId, array $data = null): EditMessageCaptionMethod
47
    {
48
        $instance = new static();
49
        $instance->chatId = $chatId;
50
        $instance->messageId = $messageId;
51
        if ($data) {
52
            $instance->fill($data);
53
        }
54
55
        return $instance;
56
    }
57
58
    /**
59
     * @param string     $inlineMessageId
60
     * @param array|null $data
61
     *
62
     * @throws BadArgumentException
63
     *
64
     * @return EditMessageCaptionMethod
65
     */
66
    public static function createInline(string $inlineMessageId, array $data = null): EditMessageCaptionMethod
67
    {
68
        $instance = new static();
69
        $instance->inlineMessageId = $inlineMessageId;
70
        if ($data) {
71
            $instance->fill($data);
72
        }
73
74
        return $instance;
75
    }
76
}
77