<?php


namespace Fifa\ConnectId\Sdk\Model\Transfer;

use DateTime;
use Fifa\ConnectId\Sdk\Util\ToString\Exception\ToStringException;
use Fifa\ConnectId\Sdk\Util\ToString\ToString;

class ResidencePermit
{
    /**
     * @var DocumentEmbedded
     * @required - required by SDK from business point of view, not required by FIFA Data Standard
     */
    public $ResidencePermitDocument;

    /**
     * @var boolean
     */
    public $HasResidencePermit;

    /**
     * Date in format "Y-m-d" (ref. http://php.net/manual/en/function.date.php)
     *
     * @var string
     */
    public $ResidencePermitStartDate;

    /**
     * Date in format "Y-m-d" (ref. http://php.net/manual/en/function.date.php)
     *
     * @var string
     */
    public $ResidencePermitEndDate;

    /**
     * ResidencePermit constructor.
     */
    public function __construct()
    {
    }

    /**
     * Gets DateTime object and sets its string representation to ResidencePermitEndDate property
     *
     * @param DateTime $residencePermitEndDate
     * @throws ToStringException
     */
    public function setResidencePermitEndDate(DateTime $residencePermitEndDate)
    {
        $this->ResidencePermitEndDate = ToString::getValue($residencePermitEndDate);
    }

    /**
     * Gets DateTime object and sets its string representation to ResidencePermitStartDate property
     *
     * @param DateTime $residencePermitStartDate
     * @throws ToStringException
     */
    public function setResidencePermitStartDate(DateTime $residencePermitStartDate)
    {
        $this->ResidencePermitStartDate = ToString::getValue($residencePermitStartDate);
    }

    /**
     * @return string
     */
    public function __toString()
    {
        $required = '';
        if (!is_null($this->ResidencePermitDocument)) {
            $required = sprintf('ResidencePermitDocument: %s', $this->ResidencePermitDocument->__toString());
        }

        $optional = sprintf('ResidencePermitStartDate: %s, ResidencePermitEndDate: %s, HasResidencePermit: %s', $this->ResidencePermitStartDate, $this->ResidencePermitEndDate, $this->HasResidencePermit);

        return sprintf('%s, %s', $required, $optional);
    }
}