PromoteChatMemberMethod::create()   A
last analyzed

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