Passed
Pull Request — master (#44)
by Nikolay
14:55
created

CopyMessageMethod   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 13
dl 0
loc 37
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 12 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\HasParseModeVariableInterface;
8
use TgBotApi\BotApiBase\Method\Interfaces\MethodInterface;
9
use TgBotApi\BotApiBase\Method\Traits\CaptionVariablesTrait;
10
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
11
use TgBotApi\BotApiBase\Method\Traits\SendToChatVariablesTrait;
12
13
/**
14
 * Use this method to copy messages of any kind. The method is analogous to the method forwardMessages, but the copied
15
 * message doesn't have a link to the original message. Returns the MessageId of the sent message on success.
16
 *
17
 * @see https://core.telegram.org/bots/api#copymessage
18
 */
19
class CopyMessageMethod implements HasParseModeVariableInterface, MethodInterface
20
{
21
    use FillFromArrayTrait;
22
    use SendToChatVariablesTrait;
23
    use CaptionVariablesTrait;
24
25
    /**
26
     * Unique identifier for the chat where the original
27
     * message was sent (or channel username in the format @channelusername).
28
     *
29
     * @var int|string
30
     */
31
    public $fromChatId;
32
33
    /**
34
     * Message identifier in the chat specified in from_chat_id.
35
     *
36
     * @var int
37
     */
38
    public $messageId;
39
40
    /**
41
     * @param $chatId
42
     * @param $fromChatId
43
     */
44 1
    public static function create($chatId, $fromChatId, int $messageId, array $data = null): CopyMessageMethod
45
    {
46 1
        $instance = new static();
47 1
        $instance->chatId = $chatId;
48 1
        $instance->fromChatId = $fromChatId;
49 1
        $instance->messageId = $messageId;
50
51 1
        if (!empty($data)) {
52 1
            $instance->fill($data);
53
        }
54
55 1
        return $instance;
56
    }
57
}
58