Voice::setDuration()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
ccs 1
cts 1
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace TelegramBot\Api\Types;
4
5
use TelegramBot\Api\BaseType;
6
use TelegramBot\Api\InvalidArgumentException;
7
use TelegramBot\Api\TypeInterface;
8
9
/**
10
 * Class Voice
11
 * This object represents a voice note.
12
 *
13
 * @package TelegramBot\Api\Types
14
 */
15
class Voice extends BaseType implements TypeInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     *
20
     * @var array
21
     */
22
    protected static $requiredParams = ['file_id', 'file_unique_id', 'duration'];
23
24
    /**
25
     * {@inheritdoc}
26
     *
27
     * @var array
28
     */
29
    protected static $map = [
30
        'file_id' => true,
31
        'file_unique_id' => true,
32
        'duration' => true,
33
        'mime_type' => true,
34
        'file_size' => true,
35
    ];
36
37
    /**
38
     * Identifier for this file, which can be used to download or reuse the file
39
     *
40
     * @var string
41
     */
42
    protected $fileId;
43
44
    /**
45
     * Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be
46
     * used to download or reuse the file.
47
     *
48
     * @var string
49
     */
50
    protected $fileUniqueId;
51
52
    /**
53
     * Duration of the audio in seconds as defined by sender
54
     *
55
     * @var int
56
     */
57
    protected $duration;
58
59
    /**
60
     * Optional. MIME type of the file as defined by sender
61
     *
62
     * @var string|null
63
     */
64
    protected $mimeType;
65
66
    /**
67
     * Optional. File size
68
     *
69
     * @var int|null
70
     */
71
    protected $fileSize;
72
73
    /**
74
     * @return string
75
     */
76 1
    public function getFileId()
77
    {
78 1
        return $this->fileId;
79
    }
80
81
    /**
82
     * @param string $fileId
83
     *
84 5
     * @return void
85
     */
86 5
    public function setFileId($fileId)
87 5
    {
88
        $this->fileId = $fileId;
89
    }
90
91
    /**
92 1
     * @return string
93
     */
94 1
    public function getFileUniqueId()
95
    {
96
        return $this->fileUniqueId;
97
    }
98
99
    /**
100 5
     * @param string $fileUniqueId
101
     *
102 5
     * @return void
103 5
     */
104
    public function setFileUniqueId($fileUniqueId)
105
    {
106
        $this->fileUniqueId = $fileUniqueId;
107
    }
108 1
109
    /**
110 1
     * @return int
111
     */
112
    public function getDuration()
113
    {
114
        return $this->duration;
115
    }
116
117
    /**
118 6
     * @param mixed $duration
119
     *
120 6
     * @throws InvalidArgumentException
121 5
     *
122 5
     * @return void
123 1
     */
124
    public function setDuration($duration)
125 5
    {
126
        if (is_integer($duration)) {
127
            $this->duration = $duration;
128
        } else {
129
            throw new InvalidArgumentException();
130 1
        }
131
    }
132 1
133
    /**
134
     * @return null|string
135
     */
136
    public function getMimeType()
137
    {
138 5
        return $this->mimeType;
139
    }
140 5
141 5
    /**
142
     * @param string $mimeType
143
     *
144
     * @return void
145
     */
146 1
    public function setMimeType($mimeType)
147
    {
148 1
        $this->mimeType = $mimeType;
149
    }
150
151
    /**
152
     * @return int|null
153
     */
154
    public function getFileSize()
155
    {
156 6
        return $this->fileSize;
157
    }
158 6
159 5
    /**
160 5
     * @param mixed $fileSize
161 1
     *
162
     * @throws InvalidArgumentException
163 5
     *
164
     * @return void
165
     */
166
    public function setFileSize($fileSize)
167
    {
168
        if (is_integer($fileSize)) {
169
            $this->fileSize = $fileSize;
170
        } else {
171
            throw new InvalidArgumentException();
172
        }
173
    }
174
}
175