Passed
Push — master ( 3bfee0...112fc6 )
by Nikolay
02:02
created

PinChatMessageMethod::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
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\FillFromArrayTrait;
9
use TgBotApi\BotApiBase\Method\Traits\MessageIdVariableTrait;
10
11
/**
12
 * Class PinChatMessageMethod.
13
 *
14
 * @see https://core.telegram.org/bots/api#pinchatmessage
15
 */
16
class PinChatMessageMethod
17
{
18
    use FillFromArrayTrait;
19
    use ChatIdVariableTrait;
20
    use MessageIdVariableTrait;
21
22
    /**
23
     * Optional. Pass True, if it is not necessary to send a notification to all chat members about the new
24
     * pinned message. Notifications are always disabled in channels.
25
     *
26
     * @var bool|null
27
     */
28
    public $disableNotification;
29
30
    /**
31
     * @param int|string $chatId
32
     * @param int        $messageId
33
     * @param array|null $data
34
     *
35
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
36
     *
37
     * @return PinChatMessageMethod
38
     */
39 3
    public static function create($chatId, int $messageId, array $data = null): PinChatMessageMethod
40
    {
41 3
        $instance = new static();
42 3
        $instance->chatId = $chatId;
43 3
        $instance->messageId = $messageId;
44 3
        if ($data) {
45 3
            $instance->fill($data);
46
        }
47
48 3
        return $instance;
49
    }
50
}
51