Completed
Push — master ( 989005...ce143f )
by Camilo
04:43
created

DeleteMessage   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 delete a message. A message can only be deleted if it was sent less than 48 hours ago. Any such
15
 * recently sent outgoing message may be deleted. Additionally, if the bot is an administrator in a group chat, it can
16
 * delete any message. If the bot is an administrator in a supergroup, it can delete messages from any other user and
17
 * service messages about people joining or leaving the group (other types of service messages may only be removed by
18
 * the group creator). In channels, bots can only remove their own messages. Returns True on success
19
 *
20
 * Objects defined as-is May 2017
21
 *
22
 * @see GetUpdates
23
 * @see https://core.telegram.org/bots/api#deletemessage
24
 */
25
class DeleteMessage extends TelegramMethods
26
{
27
    /**
28
     * Unique identifier for the target chat or username of the target channel (in the format @channelusername)
29
     * @var string
30
     */
31
    public $chat_id = '';
32
33
    /**
34
     * Identifier of the message to delete
35
     * @var int
36
     */
37
    public $message_id = 0;
38
39
    public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes
40
    {
41
        return new ResultBoolean($data->getResultBoolean(), $logger);
42
    }
43
44
    public function getMandatoryFields(): array
45
    {
46
        return [
47
            'chat_id',
48
            'message_id',
49
        ];
50
    }
51
}
52