Passed
Push — master ( 59a435...62cb7b )
by Nikolay
11:22
created

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