<?php
declare(strict_types=1);
namespace App\Domains\User\Domain\Entity;
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
#[ORM\Table(name: 'daily_user_usage')]
class DailyWordUsage
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int|null $id = null;
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(nullable: false)]
private User $user;
#[ORM\Column(type: 'integer')]
private int $count = 0;
#[ORM\Column(type: 'date')]
private DateTimeInterface $date;
public function __construct(User $user)
{
$this->user = $user;
$this->date = new DateTimeImmutable('today');
}
public function increment(): self
{
$this->count++;
return $this;
}
public function getCount(): int
{
return $this->count;
}
public function getUser(): User
{
return $this->user;
}
public function getDate(): DateTimeInterface
{
return $this->date;
}
}