UnpinChatMessageMethod::create()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\UnpinMethodAliasInterface;
8
use TgBotApi\BotApiBase\Method\Traits\ChatIdVariableTrait;
9
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
10
11
/**
12
 * Class UnpinChatMessageMethod.
13
 *
14
 * @see https://core.telegram.org/bots/api#unpinchatmessage
15
 */
16
class UnpinChatMessageMethod implements UnpinMethodAliasInterface
17
{
18
    use FillFromArrayTrait;
19
    use ChatIdVariableTrait;
20
21
    /**
22
     * Optional Identifier of a message to unpin. If not specified,
23
     * the most recent pinned message (by sending date) will be unpinned.
24
     *
25
     * @var int|null
26
     */
27
    public $messageId;
28
29
    /**
30
     * @param int|string $chatId
31
     *
32
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
33
     */
34 1
    public static function create($chatId, array $data = null): UnpinChatMessageMethod
35
    {
36 1
        $instance = new static();
37 1
        $instance->chatId = $chatId;
38
39 1
        if (!empty($data)) {
40 1
            $instance->fill($data);
41
        }
42
43 1
        return $instance;
44
    }
45
}
46