Passed
Push — master ( 94d770...d9484a )
by Armando
02:57
created

ChatMemberRestricted::getCanSendMediaMessages()   A

Complexity

Conditions 6
Paths 6

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 0
Metric Value
cc 6
eloc 6
c 0
b 0
f 0
nc 6
nop 0
dl 0
loc 8
ccs 0
cts 7
cp 0
crap 42
rs 9.2222
1
<?php
2
3
namespace Longman\TelegramBot\Entities\ChatMember;
4
5
use Longman\TelegramBot\Entities\Entity;
6
use Longman\TelegramBot\Entities\User;
7
8
/**
9
 * Class ChatMemberRestricted
10
 *
11
 * @link https://core.telegram.org/bots/api#chatmemberrestricted
12
 *
13
 * @method string getStatus()                The member's status in the chat, always “restricted”
14
 * @method User   getUser()                  Information about the user
15
 * @method bool   getIsMember()              True, if the user is a member of the chat at the moment of the request
16
 * @method bool   getCanChangeInfo()         True, if the user is allowed to change the chat title, photo and other settings
17
 * @method bool   getCanInviteUsers()        True, if the user is allowed to invite new users to the chat
18
 * @method bool   getCanPinMessages()        True, if the user is allowed to pin messages; groups and supergroups only
19
 * @method bool   getCanManageTopics()       True, if the user is allowed to create forum topics
20
 * @method bool   getCanSendMessages()       True, if the user is allowed to send text messages, contacts, locations and venues
21
 * @method bool   getCanSendAudios()         True, if the user is allowed to send audios
22
 * @method bool   getCanSendDocuments()      True, if the user is allowed to send documents
23
 * @method bool   getCanSendPhotos()         True, if the user is allowed to send photos
24
 * @method bool   getCanSendVideos()         True, if the user is allowed to send videos
25
 * @method bool   getCanSendVideoNotes()     True, if the user is allowed to send video notes
26
 * @method bool   getCanSendVoiceNotes()     True, if the user is allowed to send voice notes
27
 * @method bool   getCanSendPolls()          True, if the user is allowed to send polls
28
 * @method bool   getCanSendOtherMessages()  True, if the user is allowed to send animations, games, stickers and use inline bots
29
 * @method bool   getCanAddWebPagePreviews() True, if the user is allowed to add web page previews to their messages
30
 * @method int    getUntilDate()             Date when restrictions will be lifted for this user; unix time
31
 */
32
class ChatMemberRestricted extends Entity implements ChatMember
33
{
34
    /**
35
     * @inheritDoc
36
     */
37
    protected function subEntities(): array
38
    {
39
        return [
40
            'user' => User::class,
41
        ];
42
    }
43
44
    /**
45
     * True, if the user is allowed to send audios, documents, photos, videos, video notes OR voice notes
46
     *
47
     * @deprecated Use new fine-grained methods provided by Telegram Bot API.
48
     *
49
     * @return bool
50
     */
51
    public function getCanSendMediaMessages(): bool
52
    {
53
        return $this->getCanSendAudios() ||
54
            $this->getCanSendDocuments() ||
55
            $this->getCanSendPhotos() ||
56
            $this->getCanSendVideos() ||
57
            $this->getCanSendVideoNotes() ||
58
            $this->getCanSendVoiceNotes();
59
    }
60
}
61