Backup #1519
| ID | 1519 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/Domain/Entity/EntityTaxonomyMapping.php |
| Version | 1 |
| Typ |
modified |
| Größe | 4.2 KB |
| Hash | 684711f05e295adeb54db07dc9817e7e73124a2d86b6f16434029f8afab9aae0 |
| Datum | 2025-12-25 20:19:28 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
declare(strict_types=1);
namespace Domain\Entity;
// @responsibility: Mapping zwischen Entity und Taxonomie-Begriff
use Domain\ValueObject\Confidence;
class EntityTaxonomyMapping
{
private ?int $id = null;
private int $entityId;
private int $taxonomyTermId;
private Confidence $relevance;
private bool $validated = false;
private \DateTimeImmutable $createdAt;
private ?\DateTimeImmutable $updatedAt = null;
public function __construct()
{
$this->createdAt = new \DateTimeImmutable();
$this->relevance = Confidence::medium();
}
// Getters
public function getId(): ?int
{
return $this->id;
}
public function getEntityId(): int
{
return $this->entityId;
}
public function getTaxonomyTermId(): int
{
return $this->taxonomyTermId;
}
public function getRelevance(): Confidence
{
return $this->relevance;
}
public function isValidated(): bool
{
return $this->validated;
}
public function getCreatedAt(): \DateTimeImmutable
{
return $this->createdAt;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
// Setters
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
public function setEntityId(int $entityId): self
{
$this->entityId = $entityId;
return $this;
}
public function setTaxonomyTermId(int $taxonomyTermId): self
{
$this->taxonomyTermId = $taxonomyTermId;
return $this;
}
public function setRelevance(Confidence $relevance): self
{
$this->relevance = $relevance;
$this->touch();
return $this;
}
public function setRelevanceFromFloat(float $value): self
{
$this->relevance = Confidence::fromFloat($value);
$this->touch();
return $this;
}
public function setValidated(bool $validated): self
{
$this->validated = $validated;
$this->touch();
return $this;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
// Domain Methods
public function validate(): self
{
$this->validated = true;
$this->touch();
return $this;
}
public function invalidate(): self
{
$this->validated = false;
$this->touch();
return $this;
}
private function touch(): void
{
$this->updatedAt = new \DateTimeImmutable();
}
public function toArray(): array
{
return [
'id' => $this->id,
'entity_id' => $this->entityId,
'taxonomy_term_id' => $this->taxonomyTermId,
'relevance' => $this->relevance->value(),
'validated' => $this->validated ? 1 : 0,
'created_at' => $this->createdAt->format('Y-m-d H:i:s'),
'updated_at' => $this->updatedAt?->format('Y-m-d H:i:s'),
];
}
public static function fromArray(array $data): self
{
$mapping = new self();
if (isset($data['id'])) {
$mapping->setId((int) $data['id']);
}
if (isset($data['entity_id'])) {
$mapping->setEntityId((int) $data['entity_id']);
}
if (isset($data['taxonomy_term_id'])) {
$mapping->setTaxonomyTermId((int) $data['taxonomy_term_id']);
}
if (isset($data['relevance'])) {
$mapping->relevance = Confidence::fromFloat((float) $data['relevance']);
}
if (isset($data['validated'])) {
$mapping->validated = (bool) $data['validated'];
}
if (isset($data['created_at'])) {
$mapping->setCreatedAt(new \DateTimeImmutable($data['created_at']));
}
if (isset($data['updated_at']) && $data['updated_at'] !== null) {
$mapping->setUpdatedAt(new \DateTimeImmutable($data['updated_at']));
}
return $mapping;
}
}
Vollständig herunterladen
Aktionen
← Zurück zur Übersicht