Chat   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 14
c 1
b 0
f 0
dl 0
loc 34
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A kickMember() 0 7 1
A unbanMember() 0 3 1
A leave() 0 3 1
A restrictMember() 0 10 1
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
}