Completed
Push — master ( 62cb7b...4b7fdd )
by Nikolay
02:34
created

SendMediaGroupMethod::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Traits\ChatIdVariableTrait;
8
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
9
use TgBotApi\BotApiBase\Type\InputMedia\InputMediaPhotoType;
10
use TgBotApi\BotApiBase\Type\InputMedia\InputMediaVideoType;
11
12
/**
13
 * Class SendMediaGroupMethod.
14
 *
15
 * @see https://core.telegram.org/bots/api#sendmediagroup
16
 */
17
class SendMediaGroupMethod
18
{
19
    use FillFromArrayTrait;
20
    use ChatIdVariableTrait;
21
    /**
22
     * A JSON-serialized array describing photos and videos to be sent, must include 2–10 items.
23
     *
24
     * @var InputMediaPhotoType[]|InputMediaVideoType[]
25
     */
26
    public $media;
27
28
    /**
29
     * Optional. Sends the message silently. Users will receive a notification with no sound.
30
     *
31
     * @var bool|null
32
     */
33
    public $disableNotification;
34
35
    /**
36
     * Optional. If the message is a reply, ID of the original message.
37
     *
38
     * @var int|null
39
     */
40
    public $replyToMessageId;
41
42
    /**
43
     * @param int|string                                  $chatId
44
     * @param InputMediaPhotoType[]|InputMediaVideoType[] $media
45
     * @param array|null                                  $data
46
     *
47
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
48
     *
49
     * @return SendMediaGroupMethod
50
     */
51 2
    public static function create($chatId, $media, array $data = null): SendMediaGroupMethod
52
    {
53 2
        $instance = new static();
54 2
        $instance->chatId = $chatId;
55 2
        $instance->media = $media;
56 2
        if ($data) {
57 1
            $instance->fill($data);
58
        }
59
60 2
        return $instance;
61
    }
62
}
63