Passed
Push — main ( bd6751...4aef09 )
by Miaad
10:17
created

chat::delPhoto()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace BPT\types;
4
5
use BPT\constants\chatType;
6
use BPT\telegram\telegram;
7
use CURLFile;
8
use stdClass;
9
10
/**
11
 * This object represents a chat.
12
 */
13
class chat extends types {
0 ignored issues
show
Bug introduced by
The type BPT\types\types was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
    /** Keep all of properties which has sub properties */
15
    private const subs = [
16
        'photo' => 'BPT\types\chatPhoto',
17
        'pinned_message' => 'BPT\types\message',
18
        'permissions' => 'BPT\types\chatPermissions',
19
        'location' => 'BPT\types\chatLocation',
20
    ];
21
22
    /**
23
     * Unique identifier for this chat. This number may have more than 32 significant bits and some programming
24
     * languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a
25
     * signed 64-bit integer or double-precision float type are safe for storing this identifier.
26
     */
27
    public int $id;
28
29
    /** Type of chat, can be either “private”, “group”, “supergroup” or “channel” */
30
    public string $type;
31
32
    /** Optional. Title, for supergroups, channels and group chats */
33
    public null|string $title = null;
34
35
    /** Optional. Username, for private chats, supergroups and channels if available */
36
    public null|string $username = null;
37
38
    /** Optional. First name of the other party in a private chat */
39
    public null|string $first_name = null;
40
41
    /** Optional. Last name of the other party in a private chat */
42
    public null|string $last_name = null;
43
44
    /** Optional. True, if the supergroup chat is a forum (has topics enabled) */
45
    public null|bool $is_forum = null;
46
47
    /** Optional. Chat photo. Returned only in getChat. */
48
    public null|chatPhoto $photo = null;
49
50
    /** Optional. If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. Returned only in getChat. */
51
    public null|array $active_usernames = null;
52
53
    /** Optional. Custom emoji identifier of emoji status of the other party in a private chat. Returned only in getChat. */
54
    public null|string $emoji_status_custom_emoji_id = null;
55
56
    /** Optional. Bio of the other party in a private chat. Returned only in getChat. */
57
    public null|string $bio = null;
58
59
    /**
60
     * Optional. True, if privacy settings of the other party in the private chat allows to use
61
     * tg://user?id=<user_id> links only in chats with the user. Returned only in getChat.
62
     */
63
    public null|bool $has_private_forwards = null;
64
65
    /**
66
     * Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in
67
     * the private chat. Returned only in getChat.
68
     */
69
    public null|bool $has_restricted_voice_and_video_messages = null;
70
71
    /** Optional. True, if users need to join the supergroup before they can send messages. Returned only in getChat. */
72
    public null|bool $join_to_send_messages = null;
73
74
    /**
75
     * Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators.
76
     * Returned only in getChat.
77
     */
78
    public null|bool $join_by_request = null;
79
80
    /** Optional. Description, for groups, supergroups and channel chats. Returned only in getChat. */
81
    public null|string $description = null;
82
83
    /** Optional. Primary invite link, for groups, supergroups and channel chats. Returned only in getChat. */
84
    public null|string $invite_link = null;
85
86
    /** Optional. The most recent pinned message (by sending date). Returned only in getChat. */
87
    public null|message $pinned_message = null;
88
89
    /** Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat. */
90
    public null|chatPermissions $permissions = null;
91
92
    /**
93
     * Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged
94
     * user; in seconds. Returned only in getChat.
95
     */
96
    public null|int $slow_mode_delay = null;
97
98
    /**
99
     * Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds.
100
     * Returned only in getChat.
101
     */
102
    public null|int $message_auto_delete_time = null;
103
104
    /** Optional. True, if messages from the chat can't be forwarded to other chats. Returned only in getChat. */
105
    public null|bool $has_protected_content = null;
106
107
    /** Optional. For supergroups, name of group sticker set. Returned only in getChat. */
108
    public null|string $sticker_set_name = null;
109
110
    /** Optional. True, if the bot can change the group sticker set. Returned only in getChat. */
111
    public null|bool $can_set_sticker_set = null;
112
113
    /**
114
     * Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice
115
     * versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some programming
116
     * languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed
117
     * 64 bit integer or double-precision float type are safe for storing this identifier. Returned only in getChat.
118
     */
119
    public null|int $linked_chat_id = null;
120
121
    /** Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat. */
122
    public null|chatLocation $location = null;
123
124
125
    public function __construct(stdClass|null $object = null) {
126
        if ($object != null) {
127
            parent::__construct($object, self::subs);
128
        }
129
    }
130
131
    public function isPrivate (): bool {
132
        return $this->type === chatType::PRIVATE;
133
    }
134
135
    public function isGroup (): bool {
136
        return $this->type === chatType::GROUP;
137
    }
138
139
    public function isSuperGroup (): bool {
140
        return $this->type === chatType::SUPERGROUP;
141
    }
142
143
    public function isChannel (): bool {
144
        return $this->type === chatType::CHANNEL;
145
    }
146
147
    public function leave(): responseError|bool {
148
        if ($this->isPrivate()) {
149
            return false;
150
        }
151
        return telegram::leave($this->id);
152
    }
153
154
    public function setPhoto(CURLFile|array $photo): responseError|bool {
155
        if ($this->isPrivate()) {
156
            return false;
157
        }
158
        return telegram::setChatPhoto($photo,$this->id);
159
    }
160
161
    public function delPhoto(): responseError|bool {
162
        if ($this->isPrivate()) {
163
            return false;
164
        }
165
        return telegram::deleteChatPhoto($this->id);
166
    }
167
168
    public function setTitle(string|array $title): responseError|bool {
169
        if ($this->isPrivate()) {
170
            return false;
171
        }
172
        return telegram::setChatTitle($title,$this->id);
173
    }
174
175
    public function setDescription(string|null $description = null): responseError|bool {
176
        if ($this->isPrivate()) {
177
            return false;
178
        }
179
        return telegram::setChatDescription($this->id,$description);
180
    }
181
182
    public function getAdmins(): bool|responseError|array {
183
        if ($this->isPrivate()) {
184
            return false;
185
        }
186
        return telegram::getChatAdministrators($this->id);
187
    }
188
189
    public function getMembersCount(): bool|responseError|int {
190
        if ($this->isPrivate()) {
191
            return false;
192
        }
193
        return telegram::getChatMemberCount($this->id);
194
    }
195
196
    public function getMember(int|null $user_id = null): chatMember|bool|responseError {
197
        if ($this->isPrivate()) {
198
            return false;
199
        }
200
        return telegram::getChatMember($this->id,$user_id);
201
    }
202
}
203