DeleteMessageMethod   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 7
dl 0
loc 18
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\DeleteMethodAliasInterface;
8
use TgBotApi\BotApiBase\Method\Traits\ChatIdVariableTrait;
9
use TgBotApi\BotApiBase\Method\Traits\MessageIdVariableTrait;
10
11
/**
12
 * Class DeleteMessageMethod.
13
 *
14
 * Use this method to delete a message, including service messages, with the following limitations:
15
 * - A message can only be deleted if it was sent less than 48 hours ago.
16
 * - Bots can delete outgoing messages in private chats, groups, and supergroups.
17
 * - Bots granted can_post_messages permissions can delete outgoing messages in channels.
18
 * - If the bot is an administrator of a group, it can delete any message there.
19
 * - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
20
 * Returns True on success.
21
 *
22
 * @see https://core.telegram.org/bots/api#deletemessage
23
 */
24
class DeleteMessageMethod implements DeleteMethodAliasInterface
25
{
26
    use ChatIdVariableTrait;
27
    use MessageIdVariableTrait;
28
29
    /**
30
     * @param int|string $chatId
31
     * @param int        $messageId
32
     *
33
     * @return DeleteMessageMethod
34
     */
35 1
    public static function create($chatId, int $messageId): DeleteMessageMethod
36
    {
37 1
        $instance = new static();
38 1
        $instance->chatId = $chatId;
39 1
        $instance->messageId = $messageId;
40
41 1
        return $instance;
42
    }
43
}
44