Passed
Push — master ( c05883...1d5c29 )
by Nikolay
02:30
created

DeleteMessageMethod::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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