SendAudioMethod   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 15
dl 0
loc 66
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\SendMethodAliasInterface;
8
use TgBotApi\BotApiBase\Method\Traits\CaptionVariablesTrait;
9
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
10
use TgBotApi\BotApiBase\Method\Traits\SendToChatVariablesTrait;
11
use TgBotApi\BotApiBase\Type\InputFileType;
12
13
/**
14
 * Class SendAudioMethod.
15
 *
16
 * @see https://core.telegram.org/bots/api#sendaudio
17
 */
18
class SendAudioMethod implements SendMethodAliasInterface
19
{
20
    use FillFromArrayTrait;
21
    use SendToChatVariablesTrait;
22
    use CaptionVariablesTrait;
23
    /**
24
     * Audio file to send.
25
     * Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended),
26
     * pass an HTTP URL as a String for Telegram to get an audio file from the Internet,
27
     * or upload a new one using multipart/form-data.
28
     *
29
     * @var InputFileType|string
30
     */
31
    public $audio;
32
33
    /**
34
     * Optional Duration of the audio in seconds.
35
     *
36
     * @var string|null
37
     */
38
    public $duration;
39
40
    /**
41
     * Optional. Performer.
42
     *
43
     * @var string|null
44
     */
45
    public $performer;
46
47
    /**
48
     * Optional. Track name.
49
     *
50
     * @var string|null
51
     */
52
    public $title;
53
54
    /**
55
     * Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
56
     * A thumbnail‘s width and height should not exceed 90.
57
     * Ignored if the file is not uploaded using multipart/form-data.
58
     * Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>”
59
     * if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files.
60
     *
61
     * @var InputFileType|string|null
62
     */
63
    public $thumb;
64
65
    /**
66
     * @param int|string           $chatId
67
     * @param InputFileType|string $audio
68
     * @param array|null           $data
69
     *
70
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
71
     *
72
     * @return SendAudioMethod
73
     */
74 2
    public static function create($chatId, $audio, array $data = null): SendAudioMethod
75
    {
76 2
        $instance = new static();
77 2
        $instance->chatId = $chatId;
78 2
        $instance->audio = $audio;
79 2
        if ($data) {
80 1
            $instance->fill($data);
81
        }
82
83 2
        return $instance;
84
    }
85
}
86