[backend] stabilise codebase

This commit is contained in:
2025-10-11 20:09:05 +02:00
parent 2886fa9f0c
commit 1e812c93a6
36 changed files with 487 additions and 212 deletions
+17 -69
View File
@@ -4,85 +4,33 @@ declare(strict_types=1);
namespace App\Entity;
use App\Entity\Identifier\SignalId;
use App\Repository\SignalRepository;
use App\ValueObject\Point;
use DateTimeImmutable;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: SignalRepository::class)]
#[ORM\Table(name: 'signals')]
#[ORM\Index(columns: ['created_at'], name: 'idx_signals_created_at')]
#[ORM\Index(columns: ['user_key'], name: 'idx_signals_user_key')]
class Signal
#[ORM\Index(name: 'idx_signals_created_at', columns: ['created_at'])]
#[ORM\Index(name: 'idx_signals_user_key', columns: ['user_key'])]
readonly class Signal
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
private ?int $id = null; // @phpstan-ignore property.unusedType
#[ORM\Column(type: Types::STRING, length: 64)]
private string $userKey;
#[ORM\Embedded(class: Point::class, columnPrefix: 'user_')]
private Point $userLocation;
#[ORM\Embedded(class: Point::class, columnPrefix: 'signal_')]
private Point $signalLocation;
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'created_at')]
private DateTimeImmutable $createdAt;
public function getId(): ?int
{
return $this->id;
private function __construct(
#[ORM\Column(type: Types::STRING, length: 64)] public string $userKey,
#[ORM\Embedded(class: Point::class, columnPrefix: 'user_')] public Point $userLocation,
#[ORM\Embedded(class: Point::class, columnPrefix: 'signal_')] public Point $signalLocation,
#[ORM\Id] #[ORM\GeneratedValue(strategy: 'NONE')] #[ORM\Column(type: 'uuid')] public SignalId $id = new SignalId(),
#[ORM\Column(name: 'created_at', type: Types::DATETIME_IMMUTABLE)] public \DateTimeImmutable $createdAt = new \DateTimeImmutable()
) {
}
public function getUserKey(): string
public static function create(string $userKey, Point $userLocation, Point $signalLocation): self
{
return $this->userKey;
}
public function setUserKey(string $userKey): self
{
$this->userKey = $userKey;
return $this;
}
public function getUserLocation(): Point
{
return $this->userLocation;
}
public function setUserLocation(Point $userLocation): self
{
$this->userLocation = $userLocation;
return $this;
}
public function getSignalLocation(): Point
{
return $this->signalLocation;
}
public function setSignalLocation(Point $signalLocation): self
{
$this->signalLocation = $signalLocation;
return $this;
}
public function getCreatedAt(): DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
return new self(
userKey: $userKey,
userLocation: $userLocation,
signalLocation: $signalLocation
);
}
}