Chat::restrictMember()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 1
nc 1
nop 3
1
<?php
2
3
4
namespace Sysbot\Telegram\ExtendedTypes;
5
6
7
use GuzzleHttp\Promise\PromiseInterface;
8
9
trait Chat
10
{
11
    use BaseChat;
12
13
    public function leave(): PromiseInterface
14
    {
15
        return $this->api->leaveChat($this->id);
16
    }
17
18
    public function kickMember(int $userId, ?int $untilDate = null, ?bool $revokeMessages = null): PromiseInterface
19
    {
20
        return $this->api->banChatMember(
21
            chatId: $this->id,
22
            userId: $userId,
23
            untilDate: $untilDate,
24
            revokeMessages: $revokeMessages
25
        );
26
    }
27
28
    public function unbanMember(int $userId, ?bool $onlyIfBanned = null): PromiseInterface
29
    {
30
        return $this->api->unbanChatMember(chatId: $this->id, userId: $userId, onlyIfBanned: $onlyIfBanned);
31
    }
32
33
    public function restrictMember(
34
        int $userId,
35
        \Sysbot\Telegram\Types\ChatPermissions $permissions,
36
        ?int $untilDate = null
37
    ): PromiseInterface {
38
        return $this->api->restrictChatMember(
39
            chatId: $this->id,
40
            userId: $userId,
41
            permissions: $permissions,
42
            untilDate: $untilDate
43
        );
44
    }
45
}