src/GamificationBundle/Entity/UserGamificationStat.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\GamificationBundle\Entity;
  3. use App\ProfileBundle\Entity\User;
  4. use DateTimeImmutable;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\CmsBundle\Entity\IdTrait;
  7. /**
  8.  * UserGamificationStat
  9.  *
  10.  * @ORM\Table(
  11.  *     name="user_gamification_stat",
  12.  *     uniqueConstraints={@ORM\UniqueConstraint(columns={"user_id"})}
  13.  * )
  14.  * @ORM\Entity(repositoryClass="App\GamificationBundle\Repository\UserGamificationStatRepository")
  15.  */
  16. class UserGamificationStat
  17. {
  18.     use IdTrait;
  19.     /**
  20.      * @ORM\OneToOne(targetEntity="App\ProfileBundle\Entity\User")
  21.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
  22.      */
  23.     private User $user;
  24.     /**
  25.      * @var int
  26.      * @ORM\Column(type="integer", options={"default":0})
  27.      */
  28.     private int $questsCompleted 0;
  29.     /**
  30.      * @var int
  31.      * @ORM\Column(type="integer", options={"default":0})
  32.      */
  33.     private int $coinsEarned 0;
  34.     /**
  35.      * @var ?DateTimeImmutable
  36.      * @ORM\Column(type="datetime_immutable", nullable=true)
  37.      */
  38.     private ?DateTimeImmutable $lastQuestCompletedAt null;
  39.     /**
  40.      * @var bool
  41.      * @ORM\Column(type="boolean", nullable=false, options={"default": false})
  42.      */
  43.     private bool $questCompletedFired false;
  44.     /**
  45.      * @var bool
  46.      * @ORM\Column(type="boolean", nullable=false, options={"default": false})
  47.      */
  48.     private bool $coinsEarnedFired false;
  49.     /**
  50.      * @var ?DateTimeImmutable
  51.      * @ORM\Column(type="datetime_immutable", nullable=true)
  52.      */
  53.     private ?DateTimeImmutable $lastIdleFiredAt null;
  54.     public function __construct(User $user)
  55.     {
  56.         $this->user $user;
  57.     }
  58.     /**
  59.      * @return User
  60.      */
  61.     public function getUser(): User
  62.     {
  63.         return $this->user;
  64.     }
  65.     /**
  66.      * @param User|null $user
  67.      * @return $this
  68.      */
  69.     public function setUser(User $user): self
  70.     {
  71.         $this->user $user;
  72.         return $this;
  73.     }
  74.     /**
  75.      * @return int
  76.      */
  77.     public function getQuestsCompleted(): int
  78.     {
  79.         return $this->questsCompleted;
  80.     }
  81.     /**
  82.      * @param int $questsCompleted
  83.      * @return $this
  84.      */
  85.     public function setQuestsCompleted(int $questsCompleted): self
  86.     {
  87.         $this->questsCompleted $questsCompleted;
  88.         return $this;
  89.     }
  90.     /**
  91.      * @param int $by
  92.      * @return $this
  93.      */
  94.     public function incrementQuestsCompleted(int $by 1): self
  95.     {
  96.         $this->questsCompleted += $by;
  97.         return $this;
  98.     }
  99.     /**
  100.      * @return int
  101.      */
  102.     public function getCoinsEarned(): int
  103.     {
  104.         return $this->coinsEarned;
  105.     }
  106.     /**
  107.      * @param int $coinsEarned
  108.      * @return $this
  109.      */
  110.     public function setCoinsEarned(int $coinsEarned): self
  111.     {
  112.         $this->coinsEarned $coinsEarned;
  113.         return $this;
  114.     }
  115.     /**
  116.      * @param int $coins
  117.      * @return $this
  118.      */
  119.     public function addCoins(int $coins): self
  120.     {
  121.         $this->coinsEarned += $coins;
  122.         return $this;
  123.     }
  124.     /**
  125.      * @return bool
  126.      */
  127.     public function isQuestCompletedFired(): bool
  128.     {
  129.         return $this->questCompletedFired;
  130.     }
  131.     /**
  132.      * @param bool $questCompletedFired
  133.      * @return $this
  134.      */
  135.     public function setQuestCompletedFired(bool $questCompletedFired): self
  136.     {
  137.         $this->questCompletedFired $questCompletedFired;
  138.         return $this;
  139.     }
  140.     /**
  141.      * @return bool
  142.      */
  143.     public function isCoinsEarnedFired(): bool
  144.     {
  145.         return $this->coinsEarnedFired;
  146.     }
  147.     /**
  148.      * @param bool $coinsEarnedFired
  149.      * @return $this
  150.      */
  151.     public function setCoinsEarnedFired(bool $coinsEarnedFired): self
  152.     {
  153.         $this->coinsEarnedFired $coinsEarnedFired;
  154.         return $this;
  155.     }
  156.     /**
  157.      * @return DateTimeImmutable|null
  158.      */
  159.     public function getLastQuestCompletedAt(): ?DateTimeImmutable
  160.     {
  161.         return $this->lastQuestCompletedAt;
  162.     }
  163.     /**
  164.      * @param DateTimeImmutable|null $lastQuestCompletedAt
  165.      * @return $this
  166.      */
  167.     public function setLastQuestCompletedAt(?DateTimeImmutable $lastQuestCompletedAt): self
  168.     {
  169.         $this->lastQuestCompletedAt $lastQuestCompletedAt;
  170.         return $this;
  171.     }
  172.     /**
  173.      * @return DateTimeImmutable|null
  174.      */
  175.     public function getLastIdleFiredAt(): ?DateTimeImmutable
  176.     {
  177.         return $this->lastIdleFiredAt;
  178.     }
  179.     /**
  180.      * @param DateTimeImmutable|null $lastIdleFiredAt
  181.      * @return $this
  182.      */
  183.     public function setLastIdleFiredAt(?DateTimeImmutable $lastIdleFiredAt): self
  184.     {
  185.         $this->lastIdleFiredAt $lastIdleFiredAt;
  186.         return $this;
  187.     }
  188. }