Completed
Push — master ( f41514...1e2a43 )
by Nikolay
02:48
created

ForwardMessageMethod::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2.0078

Importance

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