osm-labo/src/Entity/Stats.php

110 lines
2.3 KiB
PHP
Raw Normal View History

2025-05-26 11:32:53 +02:00
<?php
namespace App\Entity;
use App\Repository\StatsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: StatsRepository::class)]
class Stats
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $zone = null;
#[ORM\Column(type: Types::SMALLINT)]
private ?int $completion_percent = null;
/**
* @var Collection<int, Place>
*/
#[ORM\OneToMany(targetEntity: Place::class, mappedBy: 'stats')]
private Collection $places;
#[ORM\Column(type: Types::SMALLINT)]
private ?int $places_count = null;
public function __construct()
{
$this->places = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getZone(): ?string
{
return $this->zone;
}
public function setZone(string $zone): static
{
$this->zone = $zone;
return $this;
}
public function getCompletionPercent(): ?int
{
return $this->completion_percent;
}
public function setCompletionPercent(int $completion_percent): static
{
$this->completion_percent = $completion_percent;
return $this;
}
/**
* @return Collection<int, Place>
*/
public function getPlaces(): Collection
{
return $this->places;
}
public function addPlace(Place $place): static
{
if (!$this->places->contains($place)) {
$this->places->add($place);
$place->setStats($this);
}
return $this;
}
public function removePlace(Place $place): static
{
if ($this->places->removeElement($place)) {
// set the owning side to null (unless already changed)
if ($place->getStats() === $this) {
$place->setStats(null);
}
}
return $this;
}
public function getPlacesCount(): ?int
{
return $this->places_count;
}
public function setPlacesCount(int $places_count): static
{
$this->places_count = $places_count;
return $this;
}
}