Animation   A
last analyzed

Complexity

Total Complexity 24

Size/Duplication

Total Lines 281
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 24
eloc 53
c 2
b 1
f 1
dl 0
loc 281
ccs 0
cts 80
cp 0
rs 10

20 Methods

Rating   Name   Duplication   Size   Complexity  
A getDuration() 0 3 1
A setDuration() 0 6 2
A getFileId() 0 3 1
A setFileId() 0 3 1
A getFileUniqueId() 0 3 1
A getMimeType() 0 3 1
A getFileSize() 0 3 1
A setFileSize() 0 6 2
A setHeight() 0 6 2
A getHeight() 0 3 1
A setFileUniqueId() 0 3 1
A setMimeType() 0 3 1
A setThumb() 0 3 1
A getFileName() 0 3 1
A getThumb() 0 3 1
A setThumbnail() 0 3 1
A getThumbnail() 0 3 1
A setWidth() 0 6 2
A getWidth() 0 3 1
A setFileName() 0 3 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 Animation
11
 * This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound).
12
 *
13
 * @package TelegramBot\Api\Types
14
 */
15
class Animation extends BaseType implements TypeInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     *
20
     * @var array
21
     */
22
    protected static $requiredParams = ['file_id', 'file_unique_id', 'width', 'height', 'duration'];
23
24
    /**
25
     * {@inheritdoc}
26
     *
27
     * @var array
28
     */
29
    protected static $map = [
30
        'file_id' => true,
31
        'file_unique_id' => true,
32
        'width' => true,
33
        'height' => true,
34
        'duration' => true,
35
        'thumbnail' => PhotoSize::class,
36
        'file_name' => true,
37
        'mime_type' => true,
38
        'file_size' => true
39
    ];
40
41
    /**
42
     * Unique file identifier
43
     *
44
     * @var string
45
     */
46
    protected $fileId;
47
48
    /**
49
     * Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
50
     *
51
     * @var string
52
     */
53
    protected $fileUniqueId;
54
55
    /**
56
     * Video width as defined by sender
57
     *
58
     * @var int
59
     */
60
    protected $width;
61
62
    /**
63
     * Video height as defined by sender
64
     *
65
     * @var int
66
     */
67
    protected $height;
68
69
    /**
70
     * Duration of the video in seconds as defined by sender
71
     *
72
     * @var int
73
     */
74
    protected $duration;
75
76
    /**
77
     * Video thumbnail
78
     *
79
     * @var PhotoSize
80
     */
81
    protected $thumbnail;
82
83
    /**
84
     * Optional. Animation thumbnail as defined by sender
85
     *
86
     * @var string|null
87
     */
88
    protected $fileName;
89
90
    /**
91
     * Optional. Mime type of a file as defined by sender
92
     *
93
     * @var string|null
94
     */
95
    protected $mimeType;
96
97
    /**
98
     * Optional. File size
99
     *
100
     * @var int|null
101
     */
102
    protected $fileSize;
103
104
    /**
105
     * @return int
106
     */
107
    public function getDuration()
108
    {
109
        return $this->duration;
110
    }
111
112
    /**
113
     * @param mixed $duration
114
     * @return void
115
     * @throws InvalidArgumentException
116
     */
117
    public function setDuration($duration)
118
    {
119
        if (is_integer($duration)) {
120
            $this->duration = $duration;
121
        } else {
122
            throw new InvalidArgumentException();
123
        }
124
    }
125
126
    /**
127
     * @return string
128
     */
129
    public function getFileId()
130
    {
131
        return $this->fileId;
132
    }
133
134
    /**
135
     * @param string $fileId
136
     * @return void
137
     */
138
    public function setFileId($fileId)
139
    {
140
        $this->fileId = $fileId;
141
    }
142
143
    /**
144
     * @return string
145
     */
146
    public function getFileUniqueId()
147
    {
148
        return $this->fileUniqueId;
149
    }
150
151
    /**
152
     * @param string $fileUniqueId
153
     * @return void
154
     */
155
    public function setFileUniqueId($fileUniqueId)
156
    {
157
        $this->fileUniqueId = $fileUniqueId;
158
    }
159
160
    /**
161
     * @return int|null
162
     */
163
    public function getFileSize()
164
    {
165
        return $this->fileSize;
166
    }
167
168
    /**
169
     * @param mixed $fileSize
170
     * @return void
171
     * @throws InvalidArgumentException
172
     */
173
    public function setFileSize($fileSize)
174
    {
175
        if (is_integer($fileSize)) {
176
            $this->fileSize = $fileSize;
177
        } else {
178
            throw new InvalidArgumentException();
179
        }
180
    }
181
182
    /**
183
     * @return int
184
     */
185
    public function getHeight()
186
    {
187
        return $this->height;
188
    }
189
190
    /**
191
     * @param mixed $height
192
     * @return void
193
     * @throws InvalidArgumentException
194
     */
195
    public function setHeight($height)
196
    {
197
        if (is_integer($height)) {
198
            $this->height = $height;
199
        } else {
200
            throw new InvalidArgumentException();
201
        }
202
    }
203
204
    /**
205
     * @return null|string
206
     */
207
    public function getMimeType()
208
    {
209
        return $this->mimeType;
210
    }
211
212
    /**
213
     * @param string $mimeType
214
     * @return void
215
     */
216
    public function setMimeType($mimeType)
217
    {
218
        $this->mimeType = $mimeType;
219
    }
220
221
    /**
222
     * @return PhotoSize
223
     */
224
    public function getThumbnail()
225
    {
226
        return $this->thumbnail;
227
    }
228
229
    /**
230
     * @param PhotoSize $thumbnail
231
     * @return void
232
     */
233
    public function setThumbnail(PhotoSize $thumbnail)
234
    {
235
        $this->thumbnail = $thumbnail;
236
    }
237
238
    /**
239
     * @deprecated use getThumbnail method
240
     *
241
     * @return PhotoSize|null
242
     */
243
    public function getThumb()
244
    {
245
        return $this->getThumbnail();
246
    }
247
248
    /**
249
     * @deprecated use setThumbnail method
250
     *
251
     * @param PhotoSize $thumb
252
     *
253
     * @return void
254
     */
255
    public function setThumb($thumb)
256
    {
257
        $this->setThumbnail($thumb);
258
    }
259
260
    /**
261
     * @return null|string $fileName
262
     */
263
    public function getFileName()
264
    {
265
        return $this->fileName;
266
    }
267
268
    /**
269
     * @param string $fileName
270
     * @return void
271
     */
272
    public function setFileName($fileName)
273
    {
274
        $this->fileName = $fileName;
275
    }
276
277
    /**
278
     * @return int
279
     */
280
    public function getWidth()
281
    {
282
        return $this->width;
283
    }
284
285
    /**
286
     * @param mixed $width
287
     * @return void
288
     * @throws InvalidArgumentException
289
     */
290
    public function setWidth($width)
291
    {
292
        if (is_integer($width)) {
293
            $this->width = $width;
294
        } else {
295
            throw new InvalidArgumentException();
296
        }
297
    }
298
}
299