82
82
*/
83
83
class Mailbox
84
84
{
85
- const EXPECTED_SIZE_OF_MESSAGE_AS_ARRAY = 2 ;
85
+ public const EXPECTED_SIZE_OF_MESSAGE_AS_ARRAY = 2 ;
86
86
87
- const MAX_LENGTH_FILEPATH = 255 ;
87
+ public const MAX_LENGTH_FILEPATH = 255 ;
88
88
89
- const PART_TYPE_TWO = 2 ;
89
+ public const PART_TYPE_TWO = 2 ;
90
90
91
- const IMAP_OPTIONS_SUPPORTED_VALUES =
91
+ public const IMAP_OPTIONS_SUPPORTED_VALUES =
92
92
OP_READONLY // 2
93
93
| OP_ANONYMOUS // 4
94
94
| OP_HALFOPEN // 64
@@ -1329,7 +1329,7 @@ public function downloadAttachment(DataPartInfo $dataInfo, array $params, object
1329
1329
}
1330
1330
1331
1331
/**
1332
- * Converts a string to UTF-8
1332
+ * Converts a string to UTF-8.
1333
1333
*
1334
1334
* @param string $string MIME string to decode
1335
1335
* @param string $fromCharset Charset to convert from
@@ -1338,35 +1338,35 @@ public function downloadAttachment(DataPartInfo $dataInfo, array $params, object
1338
1338
*/
1339
1339
public function convertToUtf8 (string $ string , string $ fromCharset ): string
1340
1340
{
1341
- $ fromCharset = mb_strtolower ($ fromCharset );
1342
- $ newString = '' ;
1343
-
1344
- if ('default ' === $ fromCharset ) {
1345
- $ fromCharset = $ this ->decodeMimeStrDefaultCharset ;
1346
- }
1347
-
1348
- switch ($ fromCharset ) {
1349
- case 'default ' : // Charset default is already ASCII (not encoded)
1350
- case 'utf-8 ' : // Charset UTF-8 is OK
1351
- $ newString .= $ string ;
1352
- break ;
1353
- default :
1354
- // If charset exists in mb_list_encodings(), convert using mb_convert function
1355
- if (\in_array ($ fromCharset , $ this ->lowercase_mb_list_encodings (), true )) {
1356
- $ newString .= \mb_convert_encoding ($ string , 'UTF-8 ' , $ fromCharset );
1357
- } else {
1358
- // Fallback: Try to convert with iconv()
1359
- $ iconv_converted_string = @\iconv ($ fromCharset , 'UTF-8 ' , $ string );
1360
- if (!$ iconv_converted_string ) {
1361
- // If iconv() could also not convert, return string as it is
1362
- // (unknown charset)
1363
- $ newString .= $ string ;
1364
- } else {
1365
- $ newString .= $ iconv_converted_string ;
1366
- }
1367
- }
1368
- break ;
1369
- }
1341
+ $ fromCharset = mb_strtolower ($ fromCharset );
1342
+ $ newString = '' ;
1343
+
1344
+ if ('default ' === $ fromCharset ) {
1345
+ $ fromCharset = $ this ->decodeMimeStrDefaultCharset ;
1346
+ }
1347
+
1348
+ switch ($ fromCharset ) {
1349
+ case 'default ' : // Charset default is already ASCII (not encoded)
1350
+ case 'utf-8 ' : // Charset UTF-8 is OK
1351
+ $ newString .= $ string ;
1352
+ break ;
1353
+ default :
1354
+ // If charset exists in mb_list_encodings(), convert using mb_convert function
1355
+ if (\in_array ($ fromCharset , $ this ->lowercase_mb_list_encodings (), true )) {
1356
+ $ newString .= \mb_convert_encoding ($ string , 'UTF-8 ' , $ fromCharset );
1357
+ } else {
1358
+ // Fallback: Try to convert with iconv()
1359
+ $ iconv_converted_string = @\iconv ($ fromCharset , 'UTF-8 ' , $ string );
1360
+ if (!$ iconv_converted_string ) {
1361
+ // If iconv() could also not convert, return string as it is
1362
+ // (unknown charset)
1363
+ $ newString .= $ string ;
1364
+ } else {
1365
+ $ newString .= $ iconv_converted_string ;
1366
+ }
1367
+ }
1368
+ break ;
1369
+ }
1370
1370
1371
1371
return $ newString ;
1372
1372
}
0 commit comments