Completed
Push — master ( d60737...066901 )
by Nikolay
19s queued 12s
created

SetChatMenuButtonMethod::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 8
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Interfaces\SetMethodAliasInterface;
8
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
9
use TgBotApi\BotApiBase\Type\MenuButtonType;
10
11
/**
12
 * Class SetChatMenuButtonMethod.
13
 *
14
 * Use this method to change the bot's menu button in a private chat, or the default menu button.
15
 * Returns True on success.
16
 *
17
 * @see https://core.telegram.org/bots/api#setchatmenubutton
18
 */
19
class SetChatMenuButtonMethod implements SetMethodAliasInterface
20
{
21
    use FillFromArrayTrait;
22
23
    /**
24
     * Unique identifier for the target private chat. If not specified, default bot's menu
25
     * button will be changed
26
     *
27
     * @var integer|null
28
     */
29
    public $chatId;
30
31
    /**
32
     * Optional. A JSON-serialized object for the bot's new menu button.
33
     * Defaults to 'default' type
34
     *
35
     * @var MenuButtonType|null
36
     */
37
    public $menuButton;
38
39
40
    /**
41
     * SetChatMenuButtonMethod constructor.
42
     *
43
     * @param array|null $data
44
     *
45
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
46
     *
47
     * @return SetChatMenuButtonMethod
48
     */
49
    public static function create(array $data = null): SetChatMenuButtonMethod
50
    {
51
        $instance = new static();
52
        if ($data) {
53
            $instance->fill($data);
54
        }
55
56
        return $instance;
57
    }
58
}
59