<?php

namespace NPS\Entity;

use Doctrine\ORM\Mapping as ORM;
use DateTime;

/**
 * Abstract token entity
 * @author Lukas Korinek
 * @ORM\InheritanceType("SINGLE_TABLE")
 * @ORM\DiscriminatorColumn(name="type", type="string")
 * @ORM\DiscriminatorMap({"user_activation" = "UserActivationTokenEntity", "password_reset" = "PasswordResetTokenEntity"})
 * @ORM\Entity
 * @ORM\Table(name="`token`", indexes={@ORM\Index(name="hash_index", columns={"hash"})})
 */
abstract class AbstractTokenEntity implements IEntity
{
    use TIdProperty;

    /**
     * @ORM\Column(type="datetime", name="date_created", length=250, nullable=false)
     * @var DateTime
     */
    public $dateCreated;

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

    /**
     * @ORM\Column(type="string", name="hash", length=150)
     * @var string
     */
    public $hash;

    public function __construct()
    {
        $this->dateCreated = new \DateTime();
        $this->used = false;
    }
}

