Passed
Push — draft ( 8ec7b9...aebf0a )
by Nikolay
03:09
created

SendVoiceMethod   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 41
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
wmc 2

1 Method

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