-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathFileIdType.php
More file actions
195 lines (183 loc) · 5.23 KB
/
FileIdType.php
File metadata and controls
195 lines (183 loc) · 5.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?php declare(strict_types=1);
/**
* Type enum + helper functions.
*
* This file is part of tg-file-decoder.
* tg-file-decoder is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* tg-file-decoder is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU General Public License along with tg-file-decoder.
* If not, see <http://www.gnu.org/licenses/>.
*
* @author Daniil Gentili <daniil@daniil.it>
* @copyright 2016-2019 Daniil Gentili <daniil@daniil.it>
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
*
* @link https://github.com/tg-file-decoder Documentation
*/
namespace danog\Decoder;
use AssertionError;
/**
* Represents decoded bot API file ID type.
*
* @api
*/
enum FileIdType: string
{
/**
* Thumbnail.
*/
case THUMBNAIL = 'thumbnail';
/**
* Profile photo.
* Used for users and channels, chat photos are normal PHOTOs.
*/
case PROFILE_PHOTO = 'profile_photo';
/**
* Normal photos.
*/
case PHOTO = 'photo';
/**
* Voice messages.
*/
case VOICE = 'voice';
/**
* Video.
*/
case VIDEO = 'video';
/**
* Document.
*/
case DOCUMENT = 'document';
/**
* Secret chat document.
*/
case ENCRYPTED = 'encrypted';
/**
* Temporary document.
*/
case TEMP = 'temp';
/**
* Sticker.
*/
case STICKER = 'sticker';
/**
* Music.
*/
case AUDIO = 'audio';
/**
* GIF.
*/
case ANIMATION = 'animation';
/**
* Encrypted thumbnail.
*/
case ENCRYPTED_THUMBNAIL = 'encrypted_thumbnail';
/**
* Wallpaper.
*/
case WALLPAPER = 'wallpaper';
/**
* Round video.
*/
case VIDEO_NOTE = 'video_note';
/**
* Passport raw file.
*/
case SECURE_RAW = 'secure_raw';
/**
* Passport file.
*/
case SECURE = 'secure';
/**
* Background.
*/
case BACKGROUND = 'background';
/**
* Size.
*/
case SIZE = 'size';
/** @internal Should not be used manually. */
/**
* Obtain a bot API type ID.
*
* @internal Should not be used manually.
*/
public static function fromInnerID(int $id): self
{
return match ($id) {
0 => self::THUMBNAIL,
1 => self::PROFILE_PHOTO,
2 => self::PHOTO,
3 => self::VOICE,
4 => self::VIDEO,
5 => self::DOCUMENT,
6 => self::ENCRYPTED,
7 => self::TEMP,
8 => self::STICKER,
9 => self::AUDIO,
10 => self::ANIMATION,
11 => self::ENCRYPTED_THUMBNAIL,
12 => self::WALLPAPER,
13 => self::VIDEO_NOTE,
14 => self::SECURE_RAW,
15 => self::SECURE,
16 => self::BACKGROUND,
17 => self::SIZE,
};
}
/**
* Obtain a bot API type ID.
*
* @internal Should not be used manually.
*/
public function toInnerID(): int
{
return match ($this) {
self::THUMBNAIL => 0,
self::PROFILE_PHOTO => 1,
self::PHOTO => 2,
self::VOICE=> 3,
self::VIDEO => 4,
self::DOCUMENT=> 5,
self::ENCRYPTED => 6,
self::TEMP => 7,
self::STICKER => 8,
self::AUDIO => 9,
self::ANIMATION => 10,
self::ENCRYPTED_THUMBNAIL => 11,
self::WALLPAPER => 12,
self::VIDEO_NOTE => 13,
self::SECURE_RAW => 14,
self::SECURE => 15,
self::BACKGROUND=> 16,
self::SIZE=>17,
};
}
/**
* Convert file ID type to unique file ID type.
*/
public function toUnique(): UniqueFileIdType
{
return match ($this) {
self::PHOTO => UniqueFileIdType::PHOTO,
self::PROFILE_PHOTO => UniqueFileIdType::PHOTO,
self::THUMBNAIL => UniqueFileIdType::PHOTO,
self::ENCRYPTED_THUMBNAIL => UniqueFileIdType::PHOTO,
self::WALLPAPER => UniqueFileIdType::PHOTO,
self::VIDEO => UniqueFileIdType::DOCUMENT,
self::VOICE => UniqueFileIdType::DOCUMENT,
self::DOCUMENT => UniqueFileIdType::DOCUMENT,
self::STICKER => UniqueFileIdType::DOCUMENT,
self::AUDIO => UniqueFileIdType::DOCUMENT,
self::ANIMATION => UniqueFileIdType::DOCUMENT,
self::VIDEO_NOTE => UniqueFileIdType::DOCUMENT,
self::BACKGROUND => UniqueFileIdType::DOCUMENT,
self::SECURE => UniqueFileIdType::SECURE,
self::SECURE_RAW => UniqueFileIdType::SECURE,
self::ENCRYPTED => UniqueFileIdType::ENCRYPTED,
self::TEMP => UniqueFileIdType::TEMP,
default => throw new AssertionError("Cannot convert file ID of type ".$this->name." to a unique file ID!")
};
}
}