Completed
Push — master ( b03e4f...bb3ad1 )
by Camilo
02:00
created

SetChatTitle   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
wmc 2
lcom 0
cbo 3
dl 0
loc 27
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0

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\TelegramRawData;
11
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean;
12
13
/**
14
 * Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an
15
 * administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success
16
 *
17
 * Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off
18
 * in the target group
19
 *
20
 * Objects defined as-is july 2017
21
 *
22
 * @see https://core.telegram.org/bots/api#setchattitle
23
 */
24
class SetChatTitle extends TelegramMethods
25
{
26
    /**
27
     * Unique identifier for the target chat or username of the target supergroup or channel (in the format
28
     * @var string
29
     */
30
    public $chat_id = '';
31
32
    /**
33
     * New chat title, 1-255 characters
34
     * @var string
35
     */
36
    public $title = '';
37
38
    public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes
39
    {
40
        return new ResultBoolean($data->getResultBoolean(), $logger);
41
    }
42
43
    public function getMandatoryFields(): array
44
    {
45
        return [
46
            'chat_id',
47
            'title',
48
        ];
49
    }
50
}
51