SendVoiceMethod   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 12
dl 0
loc 41
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\HasParseModeVariableInterface;
8
use TgBotApi\BotApiBase\Method\Interfaces\SendMethodAliasInterface;
9
use TgBotApi\BotApiBase\Method\Traits\CaptionVariablesTrait;
10
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
11
use TgBotApi\BotApiBase\Method\Traits\SendToChatVariablesTrait;
12
use TgBotApi\BotApiBase\Type\InputFileType;
13
14
/**
15
 * Class SendVoiceMethod.
16
 *
17
 * @see https://core.telegram.org/bots/api#sendvoice
18
 */
19
class SendVoiceMethod implements HasParseModeVariableInterface, SendMethodAliasInterface
20
{
21
    use FillFromArrayTrait;
22
    use SendToChatVariablesTrait;
23
    use CaptionVariablesTrait;
24
25
    /**
26
     * Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended),
27
     * pass an HTTP URL as a String for Telegram to get a file from the Internet,
28
     * or upload a new one using multipart/form-data.
29
     *
30
     * @var InputFileType|string
31
     */
32
    public $voice;
33
34
    /**
35
     * Optional Duration of the voice message in seconds.
36
     *
37
     * @var string|null
38
     */
39
    public $duration;
40
41
    /**
42
     * @param int|string           $chatId
43
     * @param InputFileType|string $voice
44
     * @param array|null           $data
45
     *
46
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
47
     *
48
     * @return SendVoiceMethod
49
     */
50 2
    public static function create($chatId, $voice, array $data = null): SendVoiceMethod
51
    {
52 2
        $instance = new static();
53 2
        $instance->chatId = $chatId;
54 2
        $instance->voice = $voice;
55 2
        if ($data) {
56 1
            $instance->fill($data);
57
        }
58
59 2
        return $instance;
60
    }
61
}
62