Passed
Push — master ( c05883...1d5c29 )
by Nikolay
02:30
created

InputMediaAudioType::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
ccs 0
cts 9
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 TgBotApi\BotApiBase\Type\InputMedia;
6
7
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
8
use TgBotApi\BotApiBase\Type\InputFileType;
9
10
/**
11
 * Class InputMediaAudioType.
12
 *
13
 * @see https://core.telegram.org/bots/api#inputmediaaudio
14
 */
15
class InputMediaAudioType extends InputMediaType
16
{
17
    use FillFromArrayTrait;
18
19
    /**
20
     * Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
21
     * A thumbnail‘s width and height should not exceed 90.
22
     * Ignored if the file is not uploaded using multipart/form-data.
23
     * Thumbnails can’t be reused and can be only uploaded as a new file,
24
     * so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using
25
     * multipart/form-data under <file_attach_name>.
26
     *
27
     * @var InputFileType|string|null
28
     */
29
    public $thumb;
30
31
    /**
32
     * Optional. Duration of the audio in seconds.
33
     *
34
     * @var int|null
35
     */
36
    public $duration;
37
38
    /**
39
     * Optional. Performer of the audio.
40
     *
41
     * @var string|null
42
     */
43
    public $performer;
44
45
    /**
46
     * Optional. Title of the audio.
47
     *
48
     * @var string|null
49
     */
50
    public $title;
51
52
    /**
53
     * @param string|\SplFileInfo $media
54
     * @param array|null          $data
55
     *
56
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
57
     *
58
     * @return InputMediaAudioType
59
     */
60
    public static function create($media, array $data = null): InputMediaAudioType
61
    {
62
        $instance = new static();
63
        $instance->media = $media;
64
        $instance->type = static::TYPE_AUDIO;
65
        if ($data) {
66
            $instance->fill($data);
67
        }
68
69
        return $instance;
70
    }
71
}
72