<?php
declare(strict_types=1);
namespace App\Entity;
use App\Repository\CustomerReviewStatsRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CustomerReviewStatsRepository::class)
* @ORM\Table(
* name="customer_reviews_stats",
* uniqueConstraints={
* @ORM\UniqueConstraint(name="UNIQ_customer_reviews_stats_location", columns={"location_name"})
* }
* )
*/
class CustomerReviewStats
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @ORM\Column(name="location_name", type="string", length=512, unique=true)
*/
private string $locationName;
/**
* @ORM\Column(name="average_rating", type="decimal", precision=3, scale=2, nullable=true)
*/
private ?string $averageRating = null;
/**
* @ORM\Column(name="total_review_count", type="integer", nullable=true)
*/
private ?int $totalReviewCount = null;
/**
* @ORM\Column(name="synced_at", type="datetime_immutable")
*/
private \DateTimeImmutable $syncedAt;
public function __construct(string $locationName)
{
$this->locationName = $locationName;
$this->syncedAt = new \DateTimeImmutable();
}
public function getId(): ?int
{
return $this->id;
}
public function getLocationName(): string
{
return $this->locationName;
}
public function getAverageRating(): ?string
{
return $this->averageRating;
}
public function getTotalReviewCount(): ?int
{
return $this->totalReviewCount;
}
public function getSyncedAt(): \DateTimeImmutable
{
return $this->syncedAt;
}
public function update(?string $avg, ?int $total): void
{
$this->averageRating = $avg;
$this->totalReviewCount = $total;
$this->syncedAt = new \DateTimeImmutable();
}
}