final protected function decode(string $value): string
    {
        $parts = \imap_mime_header_decode($value);
        if (!\is_array($parts)) {
            return $value;
        }

        $decoded = '';
        foreach ($parts as $part) {
            $text = $part->text;
            if ('default' !== $part->charset) {
                $text = Transcoder::decode($text, $part->charset);
            }
            // RFC2231
            if (1 === \preg_match('/^(?<encoding>[^\']+)\'[^\']*?\'(?<urltext>.+)$/', $text, $matches)) {
                $hasInvalidChars = 1 === \preg_match('#[^%a-zA-Z0-9\-_\.\+]#', $matches['urltext']);
                $hasEscapedChars = 1 === \preg_match('#%[a-zA-Z0-9]{2}#', $matches['urltext']);
                if (!$hasInvalidChars && $hasEscapedChars) {
                    $text = Transcoder::decode(\urldecode($matches['urltext']), $matches['encoding']);
                }
            }

            $decoded .= $text;
        }

        return $decoded;
    }
final protected function decode(string $value): string
    {
        $parts = \imap_mime_header_decode($value);
        if (!\is_array($parts)) {
            return $value;
        }

        $decoded = '';
        foreach ($parts as $part) {
            $text = $part->text;
            if ('default' !== $part->charset) {
                $text = Transcoder::decode($text, $part->charset);
            }
            // RFC2231
            if (1 === \preg_match('/^(?<encoding>[^\']+)\'[^\']*?\'(?<urltext>.+)$/', $text, $matches)) {
                $hasInvalidChars = 1 === \preg_match('#[^%a-zA-Z0-9\-_\.\+]#', $matches['urltext']);
                $hasEscapedChars = 1 === \preg_match('#%[a-zA-Z0-9]{2}#', $matches['urltext']);
                if (!$hasInvalidChars && $hasEscapedChars) {
                    $text = Transcoder::decode(\urldecode($matches['urltext']), $matches['encoding']);
                }
            }

            $decoded .= $text;
        }

        return $decoded;
    }
final protected function decode ( string $ value ) : string { $ parts = \ imap_mime_header_decode ( $ value ) ; if ( ! \ is_array ( $ parts ) ) { return $ value ; } $ decoded = '' ; foreach ( $ parts as $ part ) { $ text = $ part -> text ; if ( 'default' !== $ part -> charset ) { $ text = Transcoder :: decode ( $ text , $ part -> charset ) ; } // RFC2231 if ( 1 === \ preg_match ( '/^(?<encoding>[^\']+)\'[^\']*?\'(?<urltext>.+)$/' , $ text , $ matches ) ) { $ hasInvalidChars = 1 === \ preg_match ( '#[^%a-zA-Z0-9\-_\.\+]#' , $ matches [ 'urltext' ] ) ; $ hasEscapedChars = 1 === \ preg_match ( '#%[a-zA-Z0-9]{2}#' , $ matches [ 'urltext' ] ) ; if ( ! $ hasInvalidChars && $ hasEscapedChars ) { $ text = Transcoder :: decode ( \ urldecode ( $ matches [ 'urltext' ] ) , $ matches [ 'encoding' ] ) ; } } $ decoded .= $ text ; } return $ decoded ; }
Decode value.

@param string $value

@return string
Decode value .