SetChatDescriptionMethod::create()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
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 9
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\SetMethodAliasInterface;
8
use TgBotApi\BotApiBase\Method\Traits\ChatIdVariableTrait;
9
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
10
11
/**
12
 * Class SetChatDescriptionMethod.
13
 *
14
 * @see https://core.telegram.org/bots/api#setchatdescription
15
 */
16
class SetChatDescriptionMethod implements SetMethodAliasInterface
17
{
18
    use FillFromArrayTrait;
19
    use ChatIdVariableTrait;
20
21
    /**
22
     * Optional. New chat description, 0-255 characters.
23
     *
24
     * @var string|null
25
     */
26
    public $description;
27
28
    /**
29
     * @param int|string $chatId
30
     * @param array|null $data
31
     *
32
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
33
     *
34
     * @return SetChatDescriptionMethod
35
     */
36 3
    public static function create($chatId, array $data = null): SetChatDescriptionMethod
37
    {
38 3
        $instance = new static();
39 3
        $instance->chatId = $chatId;
40 3
        if ($data) {
41 3
            $instance->fill($data, ['chatId']);
42
        }
43
44 1
        return $instance;
45
    }
46
}
47