Completed
Push — master ( e3a9f0...2572ac )
by Camilo
01:41
created

SetChatPermissions   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A bindToObject() 0 4 1
A getMandatoryFields() 0 7 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace unreal4u\TelegramAPI\Telegram\Methods;
6
7
use Psr\Log\LoggerInterface;
8
use unreal4u\TelegramAPI\Abstracts\TelegramMethods;
9
use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
10
use unreal4u\TelegramAPI\InternalFunctionality\TelegramResponse;
11
use unreal4u\TelegramAPI\Telegram\Types\ChatPermissions;
12
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean;
13
14
/**
15
 * Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a
16
 * supergroup for this to work and must have the can_restrict_members admin rights. Returns True on success
17
 *
18
 * Objects defined as-is may 2020
19
 *
20
 * @see https://core.telegram.org/bots/api#setchatpermissions
21
 */
22
class SetChatPermissions extends TelegramMethods
23
{
24
    /**
25
     * Unique identifier for the target chat or username of the target supergroup or channel (in the format
26
     * @var string
27
     */
28
    public $chat_id = '';
29
30
    /**
31
     * New default chat permissions
32
     * @var ChatPermissions
33
     */
34
    public $permissions;
35
36
    public static function bindToObject(TelegramResponse $data, LoggerInterface $logger): TelegramTypes
37
    {
38
        return new ResultBoolean($data->getResultBoolean(), $logger);
39
    }
40
41
    public function getMandatoryFields(): array
42
    {
43
        return [
44
            'chat_id',
45
            'permissions',
46
        ];
47
    }
48
}
49