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

RestrictChatMemberMethod   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Method;
6
7
use TgBotApi\BotApiBase\Method\Traits\ChatIdVariableTrait;
8
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
9
use TgBotApi\BotApiBase\Method\Traits\UserIdVariableTrait;
10
11
/**
12
 * Class RestrictChatMemberMethod.
13
 *
14
 * @see https://core.telegram.org/bots/api#restrictchatmember
15
 */
16
class RestrictChatMemberMethod
17
{
18
    use FillFromArrayTrait;
19
    use ChatIdVariableTrait;
20
    use UserIdVariableTrait;
21
22
    /**
23
     * Optional. Date when the user will be unbanned, DateTimeInterface.
24
     * If user is banned for more than 366 days or less than 30 seconds
25
     * from the current time they are considered to be banned forever.
26
     *
27
     * @var \DateTimeInterface|null
28
     */
29
    public $untilDate;
30
31
    /**
32
     * Optional. Pass True, if the user can send text messages, contacts, locations and venues.
33
     *
34
     * @var bool|null
35
     */
36
    public $canSendMessages;
37
38
    /**
39
     * Optional. Pass True, if the user can send audios, documents, photos, videos, video notes and voice notes,
40
     * implies can_send_messages.
41
     *
42
     * @var bool|null
43
     */
44
    public $canSendMediaMessages;
45
46
    /**
47
     * Optional. Pass True, if the user can send animations, games, stickers and use inline bots,
48
     * implies can_send_media_messages.
49
     *
50
     * @var bool|null
51
     */
52
    public $canSendOtherMessages;
53
54
    /**
55
     * Optional. Pass True, if the user may add web page previews to their messages, implies can_send_media_messages.
56
     *
57
     * @var bool|null
58
     */
59
    public $canAddWebPagePreviews;
60
61
    /**
62
     * @param $chatId
63
     * @param int        $userId
64
     * @param array|null $data
65
     *
66
     * @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
67
     *
68
     * @return RestrictChatMemberMethod
69
     */
70 1
    public static function create($chatId, int $userId, array $data = null): RestrictChatMemberMethod
71
    {
72 1
        $instance = new static();
73 1
        $instance->chatId = $chatId;
74 1
        $instance->userId = $userId;
75 1
        if ($data) {
76 1
            $instance->fill($data);
77
        }
78
79 1
        return $instance;
80
    }
81
}
82