<?php


namespace Fifa\ConnectId\Sdk\Model\Transfer;


class DocumentEmbedded
{
    /**
     * @var string
     */
    const CONTENT_TYPE_KEY = 'xmime:contentType';

    /**
     * @var string[]
     */
    public $_attributes;

    /**
     * @var string
     * @required
     */
    public $_content;

    /**
     * @param $base64Content
     * @param string|null $contentType
     * @return DocumentEmbedded
     */
    public static function createFromBase64String($base64Content, ?string $contentType = 'application/pdf'): DocumentEmbedded
    {
        return new self($base64Content, $contentType);
    }

    /**
     * DocEmbedded constructor.
     * @param $base64content
     * @param $contentType
     */
    private function __construct($base64content, $contentType)
    {
        $this->setContent($base64content);
        if ($contentType !== null) {
            $this->_attributes[self::CONTENT_TYPE_KEY] = $contentType;
        }
    }

    /**
     * @return string
     */
    public function __toString()
    {
        return sprintf('Content: %s, Type: %s', $this->_content, $this->_attributes[self::CONTENT_TYPE_KEY]);
    }

    private function setContent($base64Content)
    {
        $this->_content = $base64Content;
    }
}