Voice::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 14
ccs 0
cts 12
cp 0
rs 10
cc 1
nc 1
nop 6
crap 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: iGusev
5
 * Date: 17/04/16
6
 * Time: 02:12
7
 */
8
9
namespace TelegramBot\Api\Types\Inline\QueryResult;
10
11
use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup;
12
use TelegramBot\Api\Types\Inline\InputMessageContent;
13
14
/**
15
 * Class Voice
16
 *
17
 * @see https://core.telegram.org/bots/api#inlinequeryresultvoice
18
 * Represents a link to an mp3 audio file. By default, this audio file will be sent by the user.
19
 * Alternatively, you can use InputMessageContent to send a message with the specified content instead of the audio.
20
 *
21
 * Note: This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
22
 *
23
 * @package TelegramBot\Api\Types\Inline\QueryResult
24
 */
25
class Voice extends AbstractInlineQueryResult
26
{
27
    /**
28
     * {@inheritdoc}
29
     *
30
     * @var array
31
     */
32
    protected static $requiredParams = ['type', 'id', 'voice_url', 'title'];
33
34
    /**
35
     * {@inheritdoc}
36
     *
37
     * @var array
38
     */
39
    protected static $map = [
40
        'type' => true,
41
        'id' => true,
42
        'voice_url' => true,
43
        'title' => true,
44
        'voice_duration' => true,
45
        'reply_markup' => InlineKeyboardMarkup::class,
46
        'input_message_content' => InputMessageContent::class,
47
    ];
48
49
    /**
50
     * {@inheritdoc}
51
     *
52
     * @var string
53
     */
54
    protected $type = 'voice';
55
56
    /**
57
     * A valid URL for the audio file
58
     *
59
     * @var string
60
     */
61
    protected $voiceUrl;
62
63
    /**
64
     * Optional. Audio duration in seconds
65
     *
66
     * @var int|null
67
     */
68
    protected $voiceDuration;
69
70
    /**
71
     * Voice constructor
72
     *
73
     * @param string $id
74
     * @param string $voiceUrl
75
     * @param string $title
76
     * @param int|null $voiceDuration
77
     * @param InlineKeyboardMarkup|null $inlineKeyboardMarkup
78
     * @param InputMessageContent|null $inputMessageContent
79
     */
80
    public function __construct(
81
        $id,
82
        $voiceUrl,
83
        $title,
84
        $voiceDuration = null,
85
        $inlineKeyboardMarkup = null,
86
        $inputMessageContent = null
87
    ) {
88
        parent::__construct($id, $title, $inputMessageContent, $inlineKeyboardMarkup);
89
90
        $this->voiceUrl = $voiceUrl;
91
        $this->voiceDuration = $voiceDuration;
92
        $this->replyMarkup = $inlineKeyboardMarkup;
93
        $this->inputMessageContent = $inputMessageContent;
94
    }
95
96
    /**
97
     * @return string
98
     */
99
    public function getVoiceUrl()
100
    {
101
        return $this->voiceUrl;
102
    }
103
104
    /**
105
     * @param string $voiceUrl
106
     *
107
     * @return void
108
     */
109
    public function setVoiceUrl($voiceUrl)
110
    {
111
        $this->voiceUrl = $voiceUrl;
112
    }
113
114
    /**
115
     * @return int|null
116
     */
117
    public function getVoiceDuration()
118
    {
119
        return $this->voiceDuration;
120
    }
121
122
    /**
123
     * @param int|null $voiceDuration
124
     *
125
     * @return void
126
     */
127
    public function setVoiceDuration($voiceDuration)
128
    {
129
        $this->voiceDuration = $voiceDuration;
130
    }
131
}
132