SendMediaGroupMethod   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 13
dl 0
loc 49
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\MethodInterface;
8
use TgBotApi\BotApiBase\Method\Traits\ChatIdVariableTrait;
9
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
10
use TgBotApi\BotApiBase\Type\InputMedia\InputMediaAudioType;
11
use TgBotApi\BotApiBase\Type\InputMedia\InputMediaDocumentType;
12
use TgBotApi\BotApiBase\Type\InputMedia\InputMediaPhotoType;
13
use TgBotApi\BotApiBase\Type\InputMedia\InputMediaVideoType;
14
15
/**
16
 * Class SendMediaGroupMethod.
17
 *
18
 * @see https://core.telegram.org/bots/api#sendmediagroup
19
 */
20
class SendMediaGroupMethod implements MethodInterface
21
{
22
    use ChatIdVariableTrait;
23
    use FillFromArrayTrait;
24
25
    /**
26
     * A JSON-serialized array describing photos and videos to be sent, must include 2–10 items.
27
     *
28
     * @var InputMediaPhotoType[]|InputMediaVideoType[]|InputMediaAudioType[]|InputMediaDocumentType[]
29
     */
30
    public $media;
31
32
    /**
33
     * Optional. Sends the message silently. Users will receive a notification with no sound.
34
     *
35
     * @var bool|null
36
     */
37
    public $disableNotification;
38
39
    /**
40
     * Optional. If the message is a reply, ID of the original message.
41
     *
42
     * @var int|null
43
     */
44
    public $replyToMessageId;
45
46
    /**
47
     * Optional. Pass True, if the message should be sent even if the specified replied-to message is not found.
48
     *
49
     * @var bool|null
50
     */
51
    public $allowSendingWithoutReply;
52
53
    /**
54
     * @param int|string                                                                                 $chatId
55
     * @param InputMediaPhotoType[]|InputMediaVideoType[]|InputMediaAudioType[]|InputMediaDocumentType[] $media
56
     *
57
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
58
     */
59 2
    public static function create($chatId, array $media, array $data = null): SendMediaGroupMethod
60
    {
61 2
        $instance = new static();
62 2
        $instance->chatId = $chatId;
63 2
        $instance->media = $media;
64 2
        if ($data) {
65 1
            $instance->fill($data);
66
        }
67
68 2
        return $instance;
69
    }
70
}
71