InlineQueryResultGameType::create()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 11
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Type\InlineQueryResult;
6
7
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
8
9
/**
10
 * Class InlineQueryResultGameType.
11
 *
12
 * @see https://core.telegram.org/bots/api#inlinequeryresultgame
13
 */
14
class InlineQueryResultGameType extends InlineQueryResultType
15
{
16
    use FillFromArrayTrait;
17
18
    /**
19
     * Short name of the game.
20
     *
21
     * @var string
22
     */
23
    public $gameShortName;
24
25
    /**
26
     * @param string     $id
27
     * @param string     $gameShortName
28
     * @param array|null $data
29
     *
30
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
31
     *
32
     * @return InlineQueryResultGameType
33
     */
34
    public static function create(string $id, string $gameShortName, array $data = null): InlineQueryResultGameType
35
    {
36
        $instance = new static();
37
        $instance->type = static::TYPE_GAME;
38
        $instance->id = $id;
39
        $instance->gameShortName = $gameShortName;
40
        if ($data) {
41
            $instance->fill($data);
42
        }
43
44
        return $instance;
45
    }
46
}
47