Passed
Push — draft ( 8ec7b9...aebf0a )
by Nikolay
03:09
created

ForwardMessageMethod   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 47
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Greenplugin\TelegramBot\Method;
6
7
use Greenplugin\TelegramBot\Method\Traits\ChatIdVariableTrait;
8
use Greenplugin\TelegramBot\Method\Traits\FillFromArrayTrait;
9
10
/**
11
 * Class ForwardMessageMethod.
12
 *
13
 * @see https://core.telegram.org/bots/api#forwardmessage
14
 */
15
class ForwardMessageMethod
16
{
17
    use FillFromArrayTrait;
18
    use ChatIdVariableTrait;
19
    /**
20
     * Unique identifier for the chat where the original message was sent
21
     * (or channel username in the format @channelusername).
22
     *
23
     * @var int|string
24
     */
25
    public $fromChatId;
26
27
    /**
28
     * Optional. Sends the message silently. Users will receive a notification with no sound.
29
     *
30
     * @var bool|null
31
     */
32
    public $disableNotification;
33
34
    /**
35
     * Message identifier in the chat specified in from_chat_id.
36
     *
37
     * @var int
38
     */
39
    public $messageId;
40
41
    /**
42
     * @param int|string $chatId
43
     * @param int|string $fromChatId
44
     * @param int        $messageId
45
     * @param array|null $data
46
     *
47
     * @throws \Greenplugin\TelegramBot\Exception\BadArgumentException
48
     *
49
     * @return ForwardMessageMethod
50
     */
51
    public static function create($chatId, $fromChatId, int $messageId, array $data = null): ForwardMessageMethod
52
    {
53
        $instance = new static();
54
        $instance->chatId = $chatId;
55
        $instance->fromChatId = $fromChatId;
56
        $instance->$messageId = $messageId;
57
        if ($data) {
58
            $instance->fill($data);
59
        }
60
61
        return $instance;
62
    }
63
}
64