Passed
Pull Request — master (#408)
by Alexander
01:37
created

Animation::setThumb()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
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 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
    static protected $requiredParams = ['file_id', 'file_unique_id', 'width', 'height', 'duration'];
23
24
    /**
25
     * {@inheritdoc}
26
     *
27
     * @var array
28
     */
29
    static protected $map = [
30
        'file_id' => true,
31
        'file_unique_id' => true,
32
        'width' => true,
33
        'height' => true,
34
        'duration' => true,
35
        'thumb' => 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
     * Video width as defined by sender
50
     *
51
     * @var int
52
     */
53
    protected $width;
54
55
    /**
56
     * Video height as defined by sender
57
     *
58
     * @var int
59
     */
60
    protected $height;
61
62
    /**
63
     * Duration of the video in seconds as defined by sender
64
     *
65
     * @var int
66
     */
67
    protected $duration;
68
69
    /**
70
     * Video thumbnail
71
     *
72
     * @var PhotoSize
73
     */
74
    protected $thumb;
75
76
    /**
77
     * Optional. Animation thumbnail as defined by sender
78
     *
79
     * @var PhotoSize
80
     */
81
    protected $fileName;
82
83
    /**
84
     * Optional. Mime type of a file as defined by sender
85
     *
86
     * @var string
87
     */
88
    protected $mimeType;
89
90
    /**
91
     * Optional. File size
92
     *
93
     * @var int
94
     */
95
    protected $fileSize;
96
97
    /**
98
     * @return int
99
     */
100
    public function getDuration()
101
    {
102
        return $this->duration;
103
    }
104
105
    /**
106
     * @param int $duration
107
     *
108
     * @throws InvalidArgumentException
109
     */
110
    public function setDuration($duration)
111
    {
112
        if (is_integer($duration)) {
0 ignored issues
show
introduced by
The condition is_integer($duration) is always true.
Loading history...
113
            $this->duration = $duration;
114
        } else {
115
            throw new InvalidArgumentException();
116
        }
117
    }
118
119
    /**
120
     * @return string
121
     */
122
    public function getFileId()
123
    {
124
        return $this->fileId;
125
    }
126
127
    /**
128
     * @param string $fileId
129
     */
130
    public function setFileId($fileId)
131
    {
132
        $this->fileId = $fileId;
133
    }
134
135
    /**
136
     * @return int
137
     */
138
    public function getFileSize()
139
    {
140
        return $this->fileSize;
141
    }
142
143
    /**
144
     * @param int $fileSize
145
     *
146
     * @throws InvalidArgumentException
147
     */
148
    public function setFileSize($fileSize)
149
    {
150
        if (is_integer($fileSize)) {
0 ignored issues
show
introduced by
The condition is_integer($fileSize) is always true.
Loading history...
151
            $this->fileSize = $fileSize;
152
        } else {
153
            throw new InvalidArgumentException();
154
        }
155
    }
156
157
    /**
158
     * @return int
159
     */
160
    public function getHeight()
161
    {
162
        return $this->height;
163
    }
164
165
    /**
166
     * @param int $height
167
     *
168
     * @throws InvalidArgumentException
169
     */
170
    public function setHeight($height)
171
    {
172
        if (is_integer($height)) {
0 ignored issues
show
introduced by
The condition is_integer($height) is always true.
Loading history...
173
            $this->height = $height;
174
        } else {
175
            throw new InvalidArgumentException();
176
        }
177
    }
178
179
    /**
180
     * @return string
181
     */
182
    public function getMimeType()
183
    {
184
        return $this->mimeType;
185
    }
186
187
    /**
188
     * @param string $mimeType
189
     */
190
    public function setMimeType($mimeType)
191
    {
192
        $this->mimeType = $mimeType;
193
    }
194
195
    /**
196
     * @return PhotoSize
197
     */
198
    public function getThumb()
199
    {
200
        return $this->thumb;
201
    }
202
203
    /**
204
     * @param PhotoSize $thumb
205
     */
206
    public function setThumb(PhotoSize $thumb)
207
    {
208
        $this->thumb = $thumb;
209
    }
210
211
    /**
212
     * @return string $fileName
213
     */
214
    public function getFileName()
215
    {
216
        return $this->fileName;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->fileName returns the type TelegramBot\Api\Types\PhotoSize which is incompatible with the documented return type string.
Loading history...
217
    }
218
219
    /**
220
     * @param string $fileName
221
     */
222
    public function setFileName($fileName)
223
    {
224
        $this->fileName = $fileName;
0 ignored issues
show
Documentation Bug introduced by
It seems like $fileName of type string is incompatible with the declared type TelegramBot\Api\Types\PhotoSize of property $fileName.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
225
    }
226
227
    /**
228
     * @return int
229
     */
230
    public function getWidth()
231
    {
232
        return $this->width;
233
    }
234
235
    /**
236
     * @param int $width
237
     *
238
     * @throws InvalidArgumentException
239
     */
240
    public function setWidth($width)
241
    {
242
        if (is_integer($width)) {
0 ignored issues
show
introduced by
The condition is_integer($width) is always true.
Loading history...
243
            $this->width = $width;
244
        } else {
245
            throw new InvalidArgumentException();
246
        }
247
    }
248
}
249