Chat::promoteChatMember()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 10
dl 0
loc 4
rs 10

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
declare(strict_types=1);
3
4
namespace DyarWeb\SendRequest;
5
6
use DyarWeb\Base;
7
8
/**
9
 * Class Chat
10
 * @package DyarWeb
11
 */
12
class Chat
13
{
14
    /**
15
     * @param string|int $chat_id
16
     * @param int $user_id
17
     * @param int $until_date
18
     * @return object
19
     */
20
    public static function kickChatMember($chat_id, $user_id, $until_date = null)
21
    {
22
        $params = compact('chat_id', 'user_id', 'until_date');
23
        return Base::sendRequest('kickChatMember', $params);
24
    }
25
26
    /**
27
     * @param string|int $chat_id
28
     * @param int $user_id
29
     * @return object
30
     */
31
    public static function unbanChatMember($chat_id, $user_id)
32
    {
33
        $params = compact('chat_id', 'user_id');
34
        return Base::sendRequest('unbanChatMember', $params);
35
    }
36
37
    /**
38
     * @param string|int $chat_id
39
     * @param int $user_id
40
     * @param array $permissions
41
     * @param int $until_date
42
     * @return object
43
     */
44
    public static function restrictChatMember($chat_id, $user_id, $permissions, $until_date = null)
45
    {
46
        $params = compact('chat_id', 'user_id', 'permissions', 'until_date');
47
        return Base::sendRequest('restrictChatMember', $params);
48
    }
49
50
    /**
51
     * @param string|int $chat_id
52
     * @param int $user_id
53
     * @param bool $can_change_info
54
     * @param bool $can_post_messages
55
     * @param bool $can_edit_messages
56
     * @param bool $can_delete_messages
57
     * @param bool $can_invite_users
58
     * @param bool $can_restrict_members
59
     * @param bool $can_pin_messages
60
     * @param bool $can_promote_members
61
     * @return object
62
     */
63
    public static function promoteChatMember($chat_id, $user_id, $can_change_info = false, $can_post_messages = false, $can_edit_messages = false, $can_delete_messages = false, $can_invite_users = false, $can_restrict_members = false, $can_pin_messages = false, $can_promote_members = false)
64
    {
65
        $params = compact('chat_id', 'user_id', 'can_change_info', 'can_post_messages', 'can_edit_messages', 'can_delete_messages', 'can_invite_users', 'can_restrict_members', 'can_pin_messages', 'can_promote_members');
66
        return Base::sendRequest('promoteChatMember', $params);
67
    }
68
69
    /**
70
     * @param string|int $chat_id
71
     * @param int $user_id
72
     * @param string $custom_title
73
     * @return object
74
     */
75
    public static function setChatAdministratorCustomTitle($chat_id, $user_id, $custom_title)
76
    {
77
        $params = compact('chat_id', 'user_id', 'custom_title');
78
        return Base::sendRequest('setChatAdministratorCustomTitle', $params);
79
    }
80
81
    /**
82
     * @param string|int $chat_id
83
     * @param int $user_id
84
     * @param array $permissions
85
     * @return object
86
     */
87
    public static function setChatPermissions($chat_id, $permissions)
88
    {
89
        $params = compact('chat_id', 'permissions');
90
        return Base::sendRequest('setChatPermissions', $params);
91
    }
92
93
    /**
94
     * @param string|int $chat_id
95
     * @return object
96
     */
97
    public static function exportChatInviteLink($chat_id)
98
    {
99
        $params = compact('chat_id');
100
        return Base::sendRequest('exportChatInviteLink', $params);
101
    }
102
103
    /**
104
     * @param string|int $chat_id
105
     * @param string $photo
106
     * @return object
107
     */
108
    public static function setChatPhoto($chat_id, $photo)
109
    {
110
        $params = compact('chat_id', 'photo');
111
        return Base::sendRequest('setChatPhoto', $params);
112
    }
113
114
    /**
115
     * @param string|int $chat_id
116
     * @return object
117
     */
118
    public static function deleteChatPhoto($chat_id)
119
    {
120
        $params = compact('chat_id');
121
        return Base::sendRequest('deleteChatPhoto', $params);
122
    }
123
124
    /**
125
     * @param string|int $chat_id
126
     * @param string $title
127
     * @return object
128
     */
129
    public static function setChatTitle($chat_id, $title)
130
    {
131
        $params = compact('chat_id', 'title');
132
        return Base::sendRequest('setChatTitle', $params);
133
    }
134
135
    /**
136
     * @param string|int $chat_id
137
     * @param string|null $description
138
     * @return object
139
     */
140
    public static function setChatDescription($chat_id, $description = null)
141
    {
142
        $params = compact('chat_id', 'description');
143
        return Base::sendRequest('setChatDescription', $params);
144
    }
145
146
    /**
147
     * @param string|int $chat_id
148
     * @param int $message_id
149
     * @param bool $disable_notification
150
     * @return object
151
     */
152
    public static function pinChatMessage($chat_id, $message_id, $disable_notification = false)
153
    {
154
        $params = compact('chat_id', 'message_id', 'disable_notification');
155
        return Base::sendRequest('pinChatMessage', $params);
156
    }
157
158
    /**
159
     * @param string|int $chat_id
160
     * @return object
161
     */
162
    public static function unpinChatMessage($chat_id)
163
    {
164
        $params = compact('chat_id');
165
        return Base::sendRequest('unpinChatMessage', $params);
166
    }
167
168
    /**
169
     * @param string|int $chat_id
170
     * @return object
171
     */
172
    public static function leaveChat($chat_id)
173
    {
174
        $params = compact('chat_id');
175
        return Base::sendRequest('leaveChat', $params);
176
    }
177
178
    /**
179
     * @param string|int $chat_id
180
     * @return object
181
     */
182
    public static function getChat($chat_id)
183
    {
184
        $params = compact('chat_id');
185
        return Base::sendRequest('getChat', $params);
186
    }
187
188
    /**
189
     * @param string|int $chat_id
190
     * @return object
191
     */
192
    public static function getChatAdministrators($chat_id)
193
    {
194
        $params = compact('chat_id');
195
        return Base::sendRequest('getChatAdministrators', $params);
196
    }
197
198
    /**
199
     * @param string|int $chat_id
200
     * @return object
201
     */
202
    public static function getChatMembersCount($chat_id)
203
    {
204
        $params = compact('chat_id');
205
        return Base::sendRequest('getChatMembersCount', $params);
206
    }
207
208
    /**
209
     * @param string|int $chat_id
210
     * @param int $user_id
211
     * @return object
212
     */
213
    public static function getChatMember($chat_id, $user_id)
214
    {
215
        $params = compact('chat_id', 'user_id');
216
        return Base::sendRequest('getChatMember', $params);
217
    }
218
219
    /**
220
     * @param string|int $chat_id
221
     * @param string $sticker_set_name
222
     * @return object
223
     */
224
    public static function setChatStickerSet($chat_id, $sticker_set_name)
225
    {
226
        $params = compact('chat_id', 'sticker_set_name');
227
        return Base::sendRequest('setChatStickerSet', $params);
228
    }
229
230
    /**
231
     * @param string|int $chat_id
232
     * @return object
233
     */
234
    public static function deleteChatStickerSet($chat_id)
235
    {
236
        $params = compact('chat_id');
237
        return Base::sendRequest('deleteChatStickerSet', $params);
238
    }
239
240
    /**
241
     * @param string|int $chat_id
242
     * @param int|null $message_id
243
     * @return object
244
     */
245
    public static function deleteMessage($chat_id, $message_id = null)
246
    {
247
        $params = compact('chat_id', 'message_id');
248
249
        return Base::sendRequest('deleteMessage', $params);
250
    }
251
}
252