f7cloud_client/apps/mail/lib/IMAP/ImapFlag.php
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

29 lines
590 B
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 F7cloud GmbH and F7cloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Mail\IMAP;
use OCA\Mail\Exception\ImapFlagEncodingException;
class ImapFlag {
/**
* @throws ImapFlagEncodingException
*/
public function create(string $label): string {
$flag = str_replace(' ', '_', $label);
$flag = mb_convert_encoding($flag, 'UTF7-IMAP', 'UTF-8');
if ($flag === false) {
throw ImapFlagEncodingException::create($label);
}
return '$' . strtolower(mb_strcut($flag, 0, 63));
}
}