<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * Cotisation d'un utilisateur
 *
 * @ORM\Entity
 * @ORM\Table(name="cotisationinfos")
 */
class CotisationInfos
{
    /**
     * @var int
     *
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\OneToOne(targetEntity="Cotisation", cascade={"all"}, mappedBy="cotisationInfos")
     */
    protected $cotisation;

    /**
     * @var int
     *
     * @ORM\Column(name="annee", type="integer", length=4)
     */
    private $annee;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="debut", type="date")
     */
    private $debut;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="fin", type="date")
     */
    private $fin;

    /**
     * RECU
     * @var bool
     *
     * @ORM\Column(name="recu", type="boolean", nullable=false)
     */
    private $recu;


    /**
     * Constructeur
     */
    public function __construct()
    {
        $now = new \DateTime();
        $this->annee = intval($now->format('Y'));
        $this->debut = $now;
        $this->fin = new \DateTime('+1 year');
        $this->recu = false;
    }

    /**
     * @return int
     */
    public function getId(): int
    {
        return $this->id;
    }

    /**
     * @return Cotisation
     */
    public function getCotisation(): ?Cotisation
    {
        return $this->cotisation;
    }

    /**
     * @param Cotisation $cotisation
     * @return Cotisation
     */
    public function setCotisation(Cotisation $cotisation)
    {
        $this->cotisation = $cotisation;
        return $this;
    }

    /**
     * @return int
     */
    public function getAnnee(): ?int
    {
        return $this->annee;
    }

    /**
     * @param int $annee
     * @return Cotisation
     */
    public function setAnnee(int $annee)
    {
        $this->annee = $annee;
        return $this;
    }

    /**
     * @return \DateTime
     */
    public function getDebut(): ?\DateTime
    {
        return $this->debut;
    }

    /**
     * @param \DateTime $debut
     * @return Cotisation
     */
    public function setDebut(\DateTime $debut)
    {
        $this->debut = $debut;
        return $this;
    }

    /**
     * @return \DateTime
     */
    public function getFin(): ?\DateTime
    {
        return $this->fin;
    }

    /**
     * @param \DateTime $fin
     * @return Cotisation
     */
    public function setFin(\DateTime $fin)
    {
        $this->fin = $fin;
        return $this;
    }

    /**
     * @return bool
     */
    public function isRecu(): ?bool
    {
        return $this->recu;
    }

    /**
     * @param bool $recu
     * @return Cotisation
     */
    public function setRecu(bool $recu)
    {
        $this->recu = $recu;
        return $this;
    }
}
