Test Failed
Pull Request — master (#322)
by Eldar
03:04
created

Voice   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 150
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 93.55%

Importance

Changes 0
Metric Value
wmc 12
lcom 2
cbo 2
dl 0
loc 150
ccs 29
cts 31
cp 0.9355
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getFileId() 0 4 1
A setFileId() 0 4 1
A getFileUniqueId() 0 4 1
A getDuration() 0 4 1
A setDuration() 0 8 2
A getMimeType() 0 4 1
A setMimeType() 0 4 1
A getFileSize() 0 4 1
A setFileSize() 0 8 2
A setFileUniqueId() 0 4 1
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
    static protected $requiredParams = ['file_id', 'file_unique_id', 'duration'];
23
24
    /**
25
     * {@inheritdoc}
26
     *
27
     * @var array
28
     */
29
    static protected $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
63
     */
64
    protected $mimeType;
65
66
    /**
67
     * Optional. File size
68
     *
69
     * @var int
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 4
    public function setFileId($fileId)
85
    {
86 4
        $this->fileId = $fileId;
87 4
    }
88
89
    /**
90
     * @return string
91
     */
92
    public function getFileUniqueId()
93
    {
94
        return $this->fileUniqueId;
95
    }
96
97
    /**
98
     * @param string $fileUniqueId
99
     */
100 2
    public function setFileUniqueId($fileUniqueId)
101
    {
102 2
        $this->fileUniqueId = $fileUniqueId;
103 2
    }
104
105
    /**
106
     * @return int
107
     */
108 1
    public function getDuration()
109
    {
110 1
        return $this->duration;
111
    }
112
113
    /**
114
     * @param int $duration
115
     *
116
     * @throws InvalidArgumentException
117
     */
118 5
    public function setDuration($duration)
119
    {
120 5
        if (is_integer($duration)) {
121 4
            $this->duration = $duration;
122 4
        } else {
123 1
            throw new InvalidArgumentException();
124
        }
125 4
    }
126
127
    /**
128
     * @return string
129
     */
130 1
    public function getMimeType()
131
    {
132 1
        return $this->mimeType;
133
    }
134
135
    /**
136
     * @param string $mimeType
137
     */
138 4
    public function setMimeType($mimeType)
139
    {
140 4
        $this->mimeType = $mimeType;
141 4
    }
142
143
    /**
144
     * @return int
145
     */
146 1
    public function getFileSize()
147
    {
148 1
        return $this->fileSize;
149
    }
150
151
    /**
152
     * @param int $fileSize
153
     *
154
     * @throws InvalidArgumentException
155
     */
156 5
    public function setFileSize($fileSize)
157
    {
158 5
        if (is_integer($fileSize)) {
159 4
            $this->fileSize = $fileSize;
160 4
        } else {
161 1
            throw new InvalidArgumentException();
162
        }
163 4
    }
164
}
165