<?php

namespace App\Model\Entities\Components\Pool;

use App\Model\Entities\BaseEntity;
use App\Model\Entities\Security\User;
use DateTime;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="vote")
 */
class Vote extends BaseEntity
{
    /**
     * @var Answer
     * @ORM\ManyToOne(targetEntity="Answer")
     */
    protected $answer;

    /**
     * @var DateTime
     * @ORM\Column(type="datetime")
     */
    protected $votedAt;

    /**
     * @var User
     * @ORM\ManyToOne(targetEntity="App\Model\Entities\Security\User")
     */
    protected $votedBy;

    /**
     * Vote constructor.
     * @param $answer
     * @param User $votedBy
     */
    public function __construct(Answer $answer, User $votedBy)
    {
        $this->answer = $answer;
        $this->votedBy = $votedBy;
        $this->votedAt = new DateTime();
    }

    /**
     * @return Answer
     */
    public function getAnswer()
    {
        return $this->answer;
    }

    /**
     * @return DateTime
     */
    public function getVotedAt()
    {
        return $this->votedAt;
    }

    /**
     * @return User
     */
    public function getVotedBy()
    {
        return $this->votedBy;
    }

}