src/Domains/User/Domain/Entity/DailyWordUsage.php line 13

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Domains\User\Domain\Entity;
  4. use DateTimeImmutable;
  5. use DateTimeInterface;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity]
  8. #[ORM\Table(name'daily_user_usage')]
  9. class DailyWordUsage
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type'integer')]
  14.     private int|null $id null;
  15.     #[ORM\ManyToOne(targetEntityUser::class)]
  16.     #[ORM\JoinColumn(nullablefalse)]
  17.     private User $user;
  18.     #[ORM\Column(type'integer')]
  19.     private int $count 0;
  20.     #[ORM\Column(type'date')]
  21.     private DateTimeInterface $date;
  22.     public function __construct(User $user)
  23.     {
  24.         $this->user $user;
  25.         $this->date = new DateTimeImmutable('today');
  26.     }
  27.     public function increment(): self
  28.     {
  29.         $this->count++;
  30.         return $this;
  31.     }
  32.     public function getCount(): int
  33.     {
  34.         return $this->count;
  35.     }
  36.     public function getUser(): User
  37.     {
  38.         return $this->user;
  39.     }
  40.     public function getDate(): DateTimeInterface
  41.     {
  42.         return $this->date;
  43.     }
  44. }