src/Entity/CustomerReviewStats.php line 19

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use App\Repository\CustomerReviewStatsRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * @ORM\Entity(repositoryClass=CustomerReviewStatsRepository::class)
  8. * @ORM\Table(
  9. * name="customer_reviews_stats",
  10. * uniqueConstraints={
  11. * @ORM\UniqueConstraint(name="UNIQ_customer_reviews_stats_location", columns={"location_name"})
  12. * }
  13. * )
  14. */
  15. class CustomerReviewStats
  16. {
  17. /**
  18. * @ORM\Id
  19. * @ORM\GeneratedValue
  20. * @ORM\Column(type="integer")
  21. */
  22. private ?int $id = null;
  23. /**
  24. * @ORM\Column(name="location_name", type="string", length=512, unique=true)
  25. */
  26. private string $locationName;
  27. /**
  28. * @ORM\Column(name="average_rating", type="decimal", precision=3, scale=2, nullable=true)
  29. */
  30. private ?string $averageRating = null;
  31. /**
  32. * @ORM\Column(name="total_review_count", type="integer", nullable=true)
  33. */
  34. private ?int $totalReviewCount = null;
  35. /**
  36. * @ORM\Column(name="synced_at", type="datetime_immutable")
  37. */
  38. private \DateTimeImmutable $syncedAt;
  39. public function __construct(string $locationName)
  40. {
  41. $this->locationName = $locationName;
  42. $this->syncedAt = new \DateTimeImmutable();
  43. }
  44. public function getId(): ?int
  45. {
  46. return $this->id;
  47. }
  48. public function getLocationName(): string
  49. {
  50. return $this->locationName;
  51. }
  52. public function getAverageRating(): ?string
  53. {
  54. return $this->averageRating;
  55. }
  56. public function getTotalReviewCount(): ?int
  57. {
  58. return $this->totalReviewCount;
  59. }
  60. public function getSyncedAt(): \DateTimeImmutable
  61. {
  62. return $this->syncedAt;
  63. }
  64. public function update(?string $avg, ?int $total): void
  65. {
  66. $this->averageRating = $avg;
  67. $this->totalReviewCount = $total;
  68. $this->syncedAt = new \DateTimeImmutable();
  69. }
  70. }