User::setIsBot()   A
last analyzed

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 0
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 User
11
 * This object represents a Telegram user or bot.
12
 *
13
 * @package TelegramBot\Api\Types
14
 */
15
class User extends BaseType implements TypeInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     *
20
     * @var array
21
     */
22
    protected static $requiredParams = ['id', 'first_name'];
23
24
    /**
25
     * {@inheritdoc}
26
     *
27
     * @var array
28
     */
29
    protected static $map = [
30
        'id' => true,
31
        'first_name' => true,
32
        'last_name' => true,
33
        'username' => true,
34
        'language_code' => true,
35
        'is_premium' => true,
36
        'added_to_attachment_menu' => true,
37
        'can_join_groups' => true,
38
        'can_read_all_group_messages' => true,
39
        'supports_inline_queries' => true,
40
        'is_bot' => true
41
    ];
42
43
    /**
44
     * Unique identifier for this user or bot
45
     *
46
     * @var int|float
47
     */
48
    protected $id;
49
50
    /**
51
     * User‘s or bot’s first name
52
     *
53
     * @var string
54
     */
55
    protected $firstName;
56
57
    /**
58
     * Optional. User‘s or bot’s last name
59
     *
60
     * @var string|null
61
     */
62
    protected $lastName;
63
64
    /**
65
     * Optional. User‘s or bot’s username
66
     *
67
     * @var string|null
68
     */
69
    protected $username;
70
71
    /**
72
     * Optional. IETF language tag of the user's language
73
     *
74
     * @var string|null
75
     */
76
    protected $languageCode;
77
78
    /**
79
     * True, if this user is a bot
80
     *
81
     * @var bool
82
     */
83
    protected $isBot;
84
85
    /**
86
     * Optional. True, if this user is a Telegram Premium user
87
     *
88
     * @var bool|null
89
     */
90
    protected $isPremium;
91
92
    /**
93
     * Optional. True, if this user added the bot to the attachment menu
94
     *
95
     * @var bool|null
96
     */
97
    protected $addedToAttachmentMenu;
98
99
    /**
100
     * Optional. True, if the bot can be invited to groups. Returned only in getMe.
101
     *
102
     * @var bool|null
103
     */
104
    protected $canJoinGroups;
105
106
    /**
107
     * Optional. True, if privacy mode is disabled for the bot. Returned only in getMe.
108
     *
109
     * @var bool|null
110
     */
111
    protected $canReadAllGroupMessages;
112
113
    /**
114
     * Optional. True, if the bot supports inline queries. Returned only in getMe.
115
     *
116
     * @var bool|null
117
     */
118
    protected $supportsInlineQueries;
119
120
    /**
121
     * @return string
122
     */
123 3
    public function getFirstName()
124
    {
125 3
        return $this->firstName;
126
    }
127
128
    /**
129
     * @param string $firstName
130
     *
131 36
     * @return void
132
     */
133 36
    public function setFirstName($firstName)
134 36
    {
135
        $this->firstName = $firstName;
136
    }
137
138
    /**
139 6
     * @return int|float
140
     */
141 6
    public function getId()
142
    {
143
        return $this->id;
144
    }
145
146
    /**
147
     * @param mixed $id
148
     *
149 40
     * @throws InvalidArgumentException
150
     *
151 40
     * @return void
152 39
     */
153 39
    public function setId($id)
154 1
    {
155
        if (is_integer($id) || is_float($id)) {
156 39
            $this->id = $id;
157
        } else {
158
            throw new InvalidArgumentException();
159
        }
160
    }
161 3
162
    /**
163 3
     * @return null|string
164
     */
165
    public function getLastName()
166
    {
167
        return $this->lastName;
168
    }
169 36
170
    /**
171 36
     * @param string $lastName
172 36
     *
173
     * @return void
174
     */
175
    public function setLastName($lastName)
176
    {
177 3
        $this->lastName = $lastName;
178
    }
179 3
180
    /**
181
     * @return null|string
182
     */
183
    public function getUsername()
184
    {
185 36
        return $this->username;
186
    }
187 36
188 36
    /**
189
     * @param string $username
190
     *
191
     * @return void
192
     */
193 2
    public function setUsername($username)
194
    {
195 2
        $this->username = $username;
196
    }
197
198
    /**
199
     * @return null|string
200
     */
201 2
    public function getLanguageCode()
202
    {
203 2
        return $this->languageCode;
204 2
    }
205
206
    /**
207
     * @param string $languageCode
208
     *
209 1
     * @return void
210
     */
211 1
    public function setLanguageCode($languageCode)
212
    {
213
        $this->languageCode = $languageCode;
214
    }
215
216
    /**
217 4
     * @return bool
218
     */
219 4
    public function isBot()
220 4
    {
221
        return $this->isBot;
222
    }
223
224
    /**
225 1
     * @param bool $isBot
226
     *
227 1
     * @return void
228 1
     */
229
    public function setIsBot($isBot)
230
    {
231
        $this->isBot = $isBot;
232
    }
233 1
234
    /**
235 1
     * @param bool $isPremium
236
     *
237
     * @return void
238
     */
239
    public function setIsPremium($isPremium)
240
    {
241 1
        $this->isPremium = $isPremium;
242
    }
243 1
244 1
    /**
245
     * @return bool|null
246
     */
247
    public function getIsPremium()
248
    {
249 1
        return $this->isPremium;
250
    }
251 1
252
    /**
253
     * @param bool $addedToAttachmentMenu
254
     *
255
     * @return void
256
     */
257 1
    public function setAddedToAttachmentMenu($addedToAttachmentMenu)
258
    {
259 1
        $this->addedToAttachmentMenu = $addedToAttachmentMenu;
260 1
    }
261
262
    /**
263
     * @return bool|null
264
     */
265 1
    public function getAddedToAttachmentMenu()
266
    {
267 1
        return $this->addedToAttachmentMenu;
268
    }
269
270
    /**
271
     * @param bool $canJoinGroups
272
     *
273 1
     * @return void
274
     */
275 1
    public function setCanJoinGroups($canJoinGroups)
276 1
    {
277
        $this->canJoinGroups = $canJoinGroups;
278
    }
279
280
    /**
281 1
     * @return bool|null
282
     */
283 1
    public function getCanJoinGroups()
284
    {
285
        return $this->canJoinGroups;
286
    }
287
288
    /**
289 1
     * @param bool $canReadAllGroupMessages
290
     *
291 1
     * @return void
292 1
     */
293
    public function setCanReadAllGroupMessages($canReadAllGroupMessages)
294
    {
295
        $this->canReadAllGroupMessages = $canReadAllGroupMessages;
296
    }
297 1
298
    /**
299 1
     * @return bool|null
300
     */
301
    public function getCanReadAllGroupMessages()
302
    {
303
        return $this->canReadAllGroupMessages;
304
    }
305
306
    /**
307
     * @param bool $supportsInlineQueries
308
     *
309
     * @return void
310
     */
311
    public function setSupportsInlineQueries($supportsInlineQueries)
312
    {
313
        $this->supportsInlineQueries = $supportsInlineQueries;
314
    }
315
316
    /**
317
     * @return bool|null
318
     */
319
    public function getSupportsInlineQueries()
320
    {
321
        return $this->supportsInlineQueries;
322
    }
323
324
}
325