Passed
Push — master ( 59a435...62cb7b )
by Nikolay
11:22
created

PromoteChatMemberMethod::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Traits\ChatIdVariableTrait;
8
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
9
use TgBotApi\BotApiBase\Method\Traits\UserIdVariableTrait;
10
11
/**
12
 * Class PromoteChatMemberMethod.
13
 *
14
 * @see https://core.telegram.org/bots/api#promotechatmember
15
 */
16
class PromoteChatMemberMethod
17
{
18
    use FillFromArrayTrait;
19
    use ChatIdVariableTrait;
20
    use UserIdVariableTrait;
21
22
    /**
23
     * Optional. Pass True, if the administrator can change chat title, photo and other settings.
24
     *
25
     * @var bool|null
26
     */
27
    public $canChangeInfo;
28
29
    /**
30
     * Optional. Pass True, if the administrator can create channel posts, channels only.
31
     *
32
     * @var bool|null
33
     */
34
    public $canPostMessages;
35
36
    /**
37
     * Optional. Pass True, if the administrator can edit messages of other users and can pin messages, channels only.
38
     *
39
     * @var bool|null
40
     */
41
    public $canEditMessages;
42
43
    /**
44
     * Optional. Pass True, if the administrator can delete messages of other users.
45
     *
46
     * @var bool|null
47
     */
48
    public $canDeleteMessages;
49
50
    /**
51
     * Optional. Pass True, if the administrator can invite new users to the chat.
52
     *
53
     * @var bool|null
54
     */
55
    public $canInviteUsers;
56
57
    /**
58
     * Optional. Pass True, if the administrator can restrict, ban or unban chat members.
59
     *
60
     * @var bool|null
61
     */
62
    public $canRestrictMembers;
63
64
    /**
65
     * Optional. Pass True, if the administrator can pin messages, supergroups only.
66
     *
67
     * @var bool|null
68
     */
69
    public $canPinMessages;
70
71
    /**
72
     * Optional. Pass True, if the administrator can add new administrators with a subset of his own privileges
73
     * or demote administrators that he has promoted, directly or indirectly
74
     * (promoted by administrators that were appointed by him).
75
     *
76
     * @var bool|null
77
     */
78
    public $canPromoteMembers;
79
80
    /**
81
     * @param $chatId
82
     * @param $userId
83
     * @param array|null $data
84
     *
85
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
86
     *
87
     * @return PromoteChatMemberMethod
88
     */
89 1
    public static function create($chatId, $userId, array $data = null): PromoteChatMemberMethod
90
    {
91 1
        $instance = new static();
92 1
        $instance->chatId = $chatId;
93 1
        $instance->userId = $userId;
94 1
        if ($data) {
95 1
            $instance->fill($data);
96
        }
97
98 1
        return $instance;
99
    }
100
}
101