Completed
Push — master ( 4ffd06...6a7f3a )
by
unknown
05:19
created

Chat   A

Complexity

Total Complexity 25

Size/Duplication

Total Lines 282
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 82.76%

Importance

Changes 2
Bugs 2 Features 0
Metric Value
wmc 25
c 2
b 2
f 0
lcom 1
cbo 2
dl 0
loc 282
ccs 48
cts 58
cp 0.8276
rs 10

22 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A setId() 0 8 4
A getType() 0 4 1
A setType() 0 4 1
A getTitle() 0 4 1
A setTitle() 0 4 1
A getUsername() 0 4 1
A setUsername() 0 4 1
A getFirstName() 0 4 1
A setFirstName() 0 4 1
A getLastName() 0 4 1
A setLastName() 0 4 1
A getAllMembersAreAdministrators() 0 4 1
A setAllMembersAreAdministrators() 0 4 1
A getPhoto() 0 4 1
A setPhoto() 0 4 1
A getDescription() 0 4 1
A setDescription() 0 4 1
A getInviteLink() 0 4 1
A setInviteLink() 0 4 1
A getPinnedMessage() 0 4 1
A setPinnedMessage() 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
class Chat extends BaseType implements TypeInterface
10
{
11
    /**
12
     * {@inheritdoc}
13
     *
14
     * @var array
15
     */
16
    static protected $requiredParams = ['id', 'type'];
17
18
    /**
19
     * {@inheritdoc}
20
     *
21
     * @var array
22
     */
23
    static protected $map = [
24
        'id' => true,
25
        'type' => true,
26
        'title' => true,
27
        'username' => true,
28
        'first_name' => true,
29
        'last_name' => true,
30
        'all_members_are_administrators' => true,
31
        'photo' => ChatPhoto::class,
32
        'description' => true,
33
        'invite_link' => true,
34
        'pinned_message' => Message::class
35
    ];
36
37
    /**
38
     * Unique identifier for this chat, not exceeding 1e13 by absolute value
39
     *
40
     * @var int|string
41
     */
42
    protected $id;
43
44
    /**
45
     * Type of chat, can be either “private”, “group”, “supergroup” or “channel”
46
     *
47
     * @var string
48
     */
49
    protected $type;
50
51
    /**
52
     * Optional. Title, for channels and group chats
53
     *
54
     * @var string
55
     */
56
    protected $title;
57
58
    /**
59
     * Optional. Username, for private chats and channels if available
60
     *
61
     * @var string
62
     */
63
    protected $username;
64
65
    /**
66
     * Optional. First name of the other party in a private chat
67
     *
68
     * @var string
69
     */
70
    protected $firstName;
71
72
    /**
73
     * Optional. Last name of the other party in a private chat
74
     *
75
     * @var string
76
     */
77
    protected $lastName;
78
79
    protected $allMembersAreAdministrators;
80
81
    /**
82
     * Optional. Chat photo. Returned only in getChat.
83
     *
84
     * @var ChatPhoto
85
     */
86
    protected $photo;
87
88
    /**
89
     * Optional. Description, for supergroups and channel chats. Returned only in getChat.
90
     *
91
     * @var string
92
     */
93
    protected $description;
94
95
    /**
96
     * Optional. Chat invite link, for supergroups and channel chats. Returned only in getChat.
97
     *
98
     * @var string
99
     */
100
    protected $inviteLink;
101
102
    /**
103
     * Optional. Pinned message, for supergroups. Returned only in getChat.
104
     *
105
     * @var Message
106
     */
107
    protected $pinnedMessage;
108
109
    /**
110
     * @return int|string
111
     */
112 3
    public function getId()
113
    {
114 3
        return $this->id;
115
    }
116
117
    /**
118
     * @param int|string $id
119
     *
120
     * @throws InvalidArgumentException
121
     */
122 22
    public function setId($id)
123
    {
124 22
        if (is_integer($id) || is_float($id) || is_string($id)) {
125 20
            $this->id = $id;
0 ignored issues
show
Documentation Bug introduced by
It seems like $id can also be of type double. However, the property $id is declared as type integer|string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
126 20
        } else {
127 2
            throw new InvalidArgumentException();
128
        }
129 20
    }
130
131
    /**
132
     * @return string
133
     */
134 1
    public function getType()
135
    {
136 1
        return $this->type;
137
    }
138
139
    /**
140
     * @param string $type
141
     */
142 19
    public function setType($type)
143
    {
144 19
        $this->type = $type;
145 19
    }
146
147
    /**
148
     * @return string
149
     */
150 2
    public function getTitle()
151
    {
152 2
        return $this->title;
153
    }
154
155
    /**
156
     * @param string $title
157
     */
158 13
    public function setTitle($title)
159
    {
160 13
        $this->title = $title;
161 13
    }
162
163
    /**
164
     * @return string
165
     */
166 2
    public function getUsername()
167
    {
168 2
        return $this->username;
169
    }
170
171
    /**
172
     * @param string $username
173
     */
174 8
    public function setUsername($username)
175
    {
176 8
        $this->username = $username;
177 8
    }
178
179
    /**
180
     * @return string
181
     */
182 2
    public function getFirstName()
183
    {
184 2
        return $this->firstName;
185
    }
186
187
    /**
188
     * @param string $firstName
189
     */
190 8
    public function setFirstName($firstName)
191
    {
192 8
        $this->firstName = $firstName;
193 8
    }
194
195
    /**
196
     * @return string
197
     */
198 2
    public function getLastName()
199
    {
200 2
        return $this->lastName;
201
    }
202
203
    /**
204
     * @param string $lastName
205
     */
206 8
    public function setLastName($lastName)
207
    {
208 8
        $this->lastName = $lastName;
209 8
    }
210
211
    /**
212
     * @return mixed
213
     */
214 1
    public function getAllMembersAreAdministrators()
215
    {
216 1
        return $this->allMembersAreAdministrators;
217
    }
218
219
    /**
220
     * @param mixed $allMembersAreAdministrators
221
     */
222 2
    public function setAllMembersAreAdministrators($allMembersAreAdministrators)
223
    {
224 2
        $this->allMembersAreAdministrators = $allMembersAreAdministrators;
225 2
    }
226
227
    /**
228
     * @return ChatPhoto
229
     */
230 1
    public function getPhoto()
231
    {
232 1
        return $this->photo;
233
    }
234
235
    /**
236
     * @param ChatPhoto $photo
237
     */
238 2
    public function setPhoto($photo)
239
    {
240 2
        $this->photo = $photo;
241 2
    }
242
243
    /**
244
     * @return string
245
     */
246 1
    public function getDescription()
247
    {
248 1
        return $this->description;
249
    }
250
251
    /**
252
     * @param string $description
253
     */
254 2
    public function setDescription($description)
255
    {
256 2
        $this->description = $description;
257 2
    }
258
259
    /**
260
     * @return string
261
     */
262
    public function getInviteLink()
263
    {
264
        return $this->inviteLink;
265
    }
266
267
    /**
268
     * @param string $inviteLink
269
     */
270
    public function setInviteLink($inviteLink)
271
    {
272
        $this->inviteLink = $inviteLink;
273
    }
274
275
    /**
276
     * @return Message
277
     */
278
    public function getPinnedMessage()
279
    {
280
        return $this->pinnedMessage;
281
    }
282
283
    /**
284
     * @param Message $pinnedMessage
285
     */
286
    public function setPinnedMessage($pinnedMessage)
287
    {
288
        $this->pinnedMessage = $pinnedMessage;
289
    }
290
}
291