Completed
Push — master ( fcd5b4...534fe0 )
by Nikolay
09:26 queued 10s
created

ChatPermissionsType::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Type;
6
7
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait;
8
9
/**
10
 * Class ChatPermissionsType
11
 * Describes actions that a non-administrator user is allowed to take in a chat.
12
 *
13
 * @see https://core.telegram.org/bots/api#chatpermissions
14
 */
15
class ChatPermissionsType
16
{
17
    use FillFromArrayTrait;
18
19
    /**
20
     * Optional. True, if the user is allowed to send text messages, contacts, locations and venues.
21
     *
22
     * @var bool
23
     */
24
    public $canSendMessages;
25
    /**
26
     * Optional. True, if the user is allowed to send
27
     * audios, documents, photos, videos, video notes and voice notes, implies can_send_messages.
28
     *
29
     * @var bool
30
     */
31
    public $canSendMediaMessages;
32
33
    /**
34
     * Optional. True, if the user is allowed to send polls, implies can_send_messages.
35
     *
36
     * @var bool
37
     */
38
    public $canSendPolls;
39
40
    /**
41
     * Optional. True, if the user is allowed to send
42
     * animations, games, stickers and use inline bots, implies can_send_media_messages.
43
     *
44
     * @var bool
45
     */
46
    public $canSendOtherMessages;
47
48
    /**
49
     * Optional. True, if the user is allowed to add web page previews to their messages,
50
     * implies can_send_media_messages.
51
     *
52
     * @var bool
53
     */
54
    public $canAddWebPagePreviews;
55
56
    /**
57
     * Optional. True, if the user is allowed to change
58
     * the chat title, photo and other settings. Ignored in public supergroups.
59
     *
60
     * @var bool
61
     */
62
    public $canChangeInfo;
63
64
    /**
65
     * Optional. True, if the user is allowed to invite new users to the chat.
66
     *
67
     * @var bool
68
     */
69
    public $canInviteUsers;
70
71
    /**
72
     * Optional. True, if the user is allowed to pin messages. Ignored in public supergroups.
73
     *
74
     * @var bool
75
     */
76
    public $canPinMessages;
77
78
    /**
79
     * @param array|null $data
80
     *
81
     * @return ChatPermissionsType
82
     */
83 2
    public static function create(array $data = null): ChatPermissionsType
84
    {
85 2
        $instance = new static();
86 2
        if ($data) {
87 2
            $instance->fill($data);
88
        }
89
90 2
        return $instance;
91
    }
92
}
93