Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Modules\Mail\Domain\Contract;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11/**
12 * Universal MIME and Character Set Decoder Contract.
13 *
14 * Handles RFC 2047 encoded-word headers, transfer encodings, and conversions to standard UTF-8.
15 *
16 * @package App\Modules\Mail\Domain\Contract
17 */
18interface MimeDecoderInterface
19{
20    /**
21     * Decodes RFC 2047 MIME encoded-word header (e.g. =?UTF-8?B?...?= or =?ISO-8859-2?Q?...?=).
22     *
23     * @param string $rawHeader Raw email header string.
24     * @return string Normalized UTF-8 string.
25     */
26    public function decodeHeader(string $rawHeader): string;
27
28    /**
29     * Converts content from source character encoding to standard UTF-8.
30     *
31     * @param string $content Raw text bytes.
32     * @param string $charset Source charset (e.g. Windows-1250, ISO-8859-2).
33     * @return string UTF-8 string.
34     */
35    public function convertToUtf8(string $content, string $charset): string;
36
37    /**
38     * Decodes content transfer encoding (base64, quoted-printable, 7bit, 8bit).
39     *
40     * @param string $content          Payload.
41     * @param string $transferEncoding Transfer encoding header.
42     * @return string Decoded payload.
43     */
44    public function decodeTransferEncoding(string $content, string $transferEncoding): string;
45}