UnbanChatMemberMethod::create()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
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 11
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\Interfaces\UnbanMethodAliasInterface;
8
use TgBotApi\BotApiBase\Method\Traits\ChatIdVariableTrait;
9
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
10
use TgBotApi\BotApiBase\Method\Traits\UserIdVariableTrait;
11
12
/**
13
 * Class UnbanChatMemberMethod.
14
 *
15
 * @see https://core.telegram.org/bots/api#unbanchatmember
16
 */
17
class UnbanChatMemberMethod implements UnbanMethodAliasInterface
18
{
19
    use FillFromArrayTrait;
20
    use ChatIdVariableTrait;
21
    use UserIdVariableTrait;
22
23
    /**
24
     * Do nothing if the user is not banned.
25
     *
26
     * @var bool|null
27
     */
28
    public $onlyIfBanned;
29
30
    /**
31
     * @param int|string $chatId
32
     *
33
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
34
     */
35 1
    public static function create($chatId, int $userId, array $data = null): UnbanChatMemberMethod
36
    {
37 1
        $instance = new static();
38 1
        $instance->chatId = $chatId;
39 1
        $instance->userId = $userId;
40
41 1
        if (!empty($data)) {
42 1
            $instance->fill($data, ['chatId', 'userId']);
43
        }
44
45 1
        return $instance;
46
    }
47
}
48