<?php

namespace AppBundle\Entity;

use AppBundle\Utils\Traits\TimestampableTrait;
use Doctrine\ORM\Mapping as ORM;

/**
 * BookmarkUser
 *
 * @ORM\Table(name="bookmark_user")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\BookmarkUserRepository")
 * @ORM\HasLifecycleCallbacks()
 */
class BookmarkUser
{

    use TimestampableTrait;

    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var int
     *
     * @ORM\Column(name="vote", type="smallint")
     */
    private $vote;

    /**
     * @ORM\OneToOne(targetEntity="AppBundle\Entity\Bookmark", cascade={"persist","remove"})
     */
    private $bookmark;

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\User")
     */
    private $user;

    /***********************
     * OneToMany Array's
     ***********************/

    /**
     * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Note", cascade={"persist", "remove"})
     */
    private $notes;

    /***********************
     * Constructor
     ***********************/
    public function __construct(User $user = null, Bookmark $bm = null)
    {
        $this->notes = new \Doctrine\Common\Collections\ArrayCollection();
        $this->bookmark = $bm;
        $this->user = $user;

    }

    /***********************
     * Getters & Setters
     ***********************/


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

    /**
     * Set vote.
     *
     * @param int $vote
     *
     * @return BookmarkUser
     */
    public function setVote($vote)
    {
        $this->vote = $vote;

        return $this;
    }

    /**
     * Get vote.
     *
     * @return int
     */
    public function getVote()
    {
        return $this->vote;
    }

    /**
     * Add note.
     *
     * @param \AppBundle\Entity\Note $note
     *
     * @return BookmarkUser
     */
    public function addNote(\AppBundle\Entity\Note $note)
    {
        $this->notes[] = $note;

        return $this;
    }

    /**
     * Remove note.
     *
     * @param \AppBundle\Entity\Note $note
     *
     * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
     */
    public function removeNote(\AppBundle\Entity\Note $note)
    {
        return $this->notes->removeElement($note);
    }

    /**
     * Get notes.
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getNotes()
    {
        return $this->notes;
    }

    /**
     * Set bookmark.
     *
     * @param \AppBundle\Entity\Bookmark|null $bookmark
     *
     * @return BookmarkUser
     */
    public function setBookmark(\AppBundle\Entity\Bookmark $bookmark = null)
    {
        $this->bookmark = $bookmark;

        return $this;
    }

    /**
     * Get bookmark.
     *
     * @return \AppBundle\Entity\Bookmark|null
     */
    public function getBookmark()
    {
        return $this->bookmark;
    }

    /**
     * Set user.
     *
     * @param \AppBundle\Entity\User|null $user
     *
     * @return BookmarkUser
     */
    public function setUser(\AppBundle\Entity\User $user = null)
    {
        $this->user = $user;

        return $this;
    }

    /**
     * Get user.
     *
     * @return \AppBundle\Entity\User|null
     */
    public function getUser()
    {
        return $this->user;
    }
}
