Passed
Push — master ( 59a435...62cb7b )
by Nikolay
11:22
created

SendGameMethod::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\FillFromArrayTrait;
8
use TgBotApi\BotApiBase\Method\Traits\ReplyMarkupVariableTrait;
9
10
/**
11
 * Class SendGameType.
12
 *
13
 * @see https://core.telegram.org/bots/api#sendgame
14
 */
15
class SendGameMethod
16
{
17
    use FillFromArrayTrait;
18
    use ReplyMarkupVariableTrait;
19
20
    /**
21
     * Unique identifier for the target chat.
22
     *
23
     * @var int
24
     */
25
    public $chatId;
26
27
    /**
28
     * Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
29
     *
30
     * @var string
31
     */
32
    public $gameShortName;
33
34
    /**
35
     * Sends the message silently. Users will receive a notification with no sound.
36
     *
37
     * @var bool|null
38
     */
39
    public $disableNotification;
40
41
    /**
42
     * If the message is a reply, ID of the original message.
43
     *
44
     * @var int|null
45
     */
46
    public $replyToMessageId;
47
48
    /**
49
     * @param int        $chatId
50
     * @param string     $gameShortName
51
     * @param array|null $data
52
     *
53
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
54
     *
55
     * @return SendGameMethod
56
     */
57 1
    public static function create(int $chatId, string $gameShortName, array $data = null): SendGameMethod
58
    {
59 1
        $instance = new static();
60 1
        $instance->chatId = $chatId;
61 1
        $instance->gameShortName = $gameShortName;
62 1
        if ($data) {
63 1
            $instance->fill($data);
64
        }
65
66 1
        return $instance;
67
    }
68
}
69