final public function getDecodedContent(): string
    {
        if (null === $this->decodedContent) {
            if (self::ENCODING_UNKNOWN === $this->getEncoding()) {
                throw new UnexpectedEncodingException('Cannot decode a content with an uknown encoding');
            }

            $content = $this->getContent();
            if (self::ENCODING_BASE64 === $this->getEncoding()) {
                $content = \base64_decode($content, false);
            } elseif (self::ENCODING_QUOTED_PRINTABLE === $this->getEncoding()) {
                $content = \quoted_printable_decode($content);
            }

            if (false === $content) {
                throw new UnexpectedEncodingException('Cannot decode content');
            }

            // If this part is a text part, convert its charset to UTF-8.
            // We don't want to decode an attachment's charset.
            if (!$this instanceof Attachment && null !== $this->getCharset() && self::TYPE_TEXT === $this->getType()) {
                $content = Transcoder::decode($content, $this->getCharset());
            }

            $this->decodedContent = $content;
        }

        return $this->decodedContent;
    }
final public function getDecodedContent(): string
    {
        if (null === $this->decodedContent) {
            if (self::ENCODING_UNKNOWN === $this->getEncoding()) {
                throw new UnexpectedEncodingException('Cannot decode a content with an uknown encoding');
            }

            $content = $this->getContent();
            if (self::ENCODING_BASE64 === $this->getEncoding()) {
                $content = \base64_decode($content, false);
            } elseif (self::ENCODING_QUOTED_PRINTABLE === $this->getEncoding()) {
                $content = \quoted_printable_decode($content);
            }

            if (false === $content) {
                throw new UnexpectedEncodingException('Cannot decode content');
            }

            // If this part is a text part, convert its charset to UTF-8.
            // We don't want to decode an attachment's charset.
            if (!$this instanceof Attachment && null !== $this->getCharset() && self::TYPE_TEXT === $this->getType()) {
                $content = Transcoder::decode($content, $this->getCharset());
            }

            $this->decodedContent = $content;
        }

        return $this->decodedContent;
    }
final public function getDecodedContent ( ) : string { if ( null === $ this -> decodedContent ) { if ( self :: ENCODING_UNKNOWN === $ this -> getEncoding ( ) ) { throw new UnexpectedEncodingException ( 'Cannot decode a content with an uknown encoding' ) ; } $ content = $ this -> getContent ( ) ; if ( self :: ENCODING_BASE64 === $ this -> getEncoding ( ) ) { $ content = \ base64_decode ( $ content , false ) ; } elseif ( self :: ENCODING_QUOTED_PRINTABLE === $ this -> getEncoding ( ) ) { $ content = \ quoted_printable_decode ( $ content ) ; } if ( false === $ content ) { throw new UnexpectedEncodingException ( 'Cannot decode content' ) ; } // If this part is a text part, convert its charset to UTF-8. // We don't want to decode an attachment's charset. if ( ! $ this instanceof Attachment && null !== $ this -> getCharset ( ) && self :: TYPE_TEXT === $ this -> getType ( ) ) { $ content = Transcoder :: decode ( $ content , $ this -> getCharset ( ) ) ; } $ this -> decodedContent = $ content ; } return $ this -> decodedContent ; }
Get decoded part content.

@return string
Get decoded part content .