Completed
Push — master ( 5f8f6d...c7964b )
by Gusev
02:56
created

Voice::getVoiceDuration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
c 1
b 0
f 0
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
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#inlinequeryresultaudio
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 input_message_content 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
    static protected $requiredParams = ['type', 'id', 'voice_url', 'title'];
33
34
    /**
35
     * {@inheritdoc}
36
     *
37
     * @var array
38
     */
39
    static protected $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
    /**
65
     * Optional. Audio duration in seconds
66
     *
67
     * @var int
68
     */
69
    protected $voiceDuration;
70
71
    /**
72
     * Voice constructor
73
     *
74
     * @param string $id
75
     * @param string $voiceUrl
76
     * @param string $title
77
     * @param int|null $voiceDuration
78
     * @param InlineKeyboardMarkup|null $inlineKeyboardMarkup
79
     * @param InputMessageContent|null $inputMessageContent
80
     */
81
    public function __construct(
82
        $id,
83
        $voiceUrl,
84
        $title,
85
        $voiceDuration = null,
86
        $inlineKeyboardMarkup = null,
87
        $inputMessageContent = null
88
    ) {
89
        parent::__construct($id, $title, $inputMessageContent, $inlineKeyboardMarkup);
90
91
        $this->voiceUrl = $voiceUrl;
92
        $this->voiceDuration = $voiceDuration;
93
        $this->replyMarkup = $inlineKeyboardMarkup;
94
        $this->inputMessageContent = $inputMessageContent;
95
    }
96
97
    /**
98
     * @return string
99
     */
100
    public function getVoiceUrl()
101
    {
102
        return $this->voiceUrl;
103
    }
104
105
    /**
106
     * @param string $voiceUrl
107
     */
108
    public function setVoiceUrl($voiceUrl)
109
    {
110
        $this->voiceUrl = $voiceUrl;
111
    }
112
113
    /**
114
     * @return int
115
     */
116
    public function getVoiceDuration()
117
    {
118
        return $this->voiceDuration;
119
    }
120
121
    /**
122
     * @param int $voiceDuration
123
     */
124
    public function setVoiceDuration($voiceDuration)
125
    {
126
        $this->voiceDuration = $voiceDuration;
127
    }
128
}
129