UnbanChatMemberMethod   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 11
dl 0
loc 29
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 11 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