Completed
Push — master ( 588078...30ae0c )
by Nikolay
04:51 queued 02:15
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\Method\Interfaces\HasParseModeVariableInterface;
8
use Greenplugin\TelegramBot\Method\Traits\EditMessageVariablesTrait;
9
use Greenplugin\TelegramBot\Method\Traits\FillFromArrayTrait;
10
11
/**
12
 * Class EditMessageCaptionMethod.
13
 *
14
 * @see https://core.telegram.org/bots/api#editmessagecaption
15
 */
16
class EditMessageCaptionMethod implements HasParseModeVariableInterface
17
{
18
    use FillFromArrayTrait;
19
    use EditMessageVariablesTrait;
20
21
    /**
22
     * Optional. New caption of the message.
23
     *
24
     * @var string|null
25
     */
26
    public $caption;
27
28
    /**
29
     * Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic,
30
     * fixed-width text or inline URLs in the media caption.
31
     *
32
     * @var string|null
33
     */
34
    public $parseMode;
35
36
    /**
37
     * EditMessageCaptionMethod constructor.
38
     *
39
     * @param int|string $chatId
40
     * @param array|null $data
41
     *
42
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
43
     */
44
    public function __construct($chatId, array $data = null)
45
    {
46
        $this->chatId = $chatId;
47
        if ($data) {
48
            $this->fill($data);
49
        }
50
    }
51
52
    /**
53
     * @param int|string $chatId
54
     * @param int        $messageId
55
     * @param array|null $data
56
     *
57
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
58
     *
59
     * @return EditMessageCaptionMethod
60
     */
61
    public static function create($chatId, int $messageId, array $data = null): EditMessageCaptionMethod
62
    {
63
        $instance = new self($chatId, $data);
64
        $instance->messageId = $messageId;
65
66
        return $instance;
67
    }
68
69
    /**
70
     * @param int|string $chatId
71
     * @param string     $inlineMessageId
72
     * @param array|null $data
73
     *
74
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
75
     *
76
     * @return EditMessageCaptionMethod
77
     */
78
    public static function createInline($chatId, string $inlineMessageId, array $data = null): EditMessageCaptionMethod
79
    {
80
        $instance = new self($chatId, $data);
81
        $instance->inlineMessageId = $inlineMessageId;
82
83
        return $instance;
84
    }
85
}
86