Antwortmöglichkeit

This commit is contained in:
2026-06-15 22:32:00 +02:00
parent f13a2c6f1e
commit 6f6e53a483
6 changed files with 213 additions and 29 deletions
+27 -4
View File
@@ -3,9 +3,8 @@
/**
* Repräsentiert einen Kommentar unter einem Beitrag.
*
* Ein Kommentar besteht aus einer eindeutigen ID,
* der ID des zugehörigen Beitrags, dem Autor,
* dem Inhalt sowie dem Erstellungsdatum.
* Ein Kommentar kann entweder ein Hauptkommentar sein
* oder eine Antwort auf einen anderen Kommentar.
*
* @author Caroline Schulte
*/
@@ -13,6 +12,7 @@ class Comment
{
private int $id;
private int $articleId;
private ?int $parentCommentId;
private string $author;
private string $content;
private string $created;
@@ -22,6 +22,7 @@ class Comment
*
* @param int $id Eindeutige ID des Kommentars
* @param int $articleId ID des zugehörigen Beitrags
* @param int|null $parentCommentId ID des Eltern-Kommentars oder null
* @param string $author Autor des Kommentars
* @param string $content Inhalt des Kommentars
* @param string $created Erstellungsdatum des Kommentars
@@ -29,12 +30,14 @@ class Comment
public function __construct(
int $id,
int $articleId,
?int $parentCommentId,
string $author,
string $content,
string $created
) {
$this->id = $id;
$this->articleId = $articleId;
$this->parentCommentId = $parentCommentId;
$this->author = $author;
$this->content = $content;
$this->created = $created;
@@ -60,6 +63,26 @@ class Comment
return $this->articleId;
}
/**
* Gibt die ID des Eltern-Kommentars zurück.
*
* @return int|null ID des Eltern-Kommentars oder null
*/
public function getParentCommentId(): ?int
{
return $this->parentCommentId;
}
/**
* Gibt zurück, ob der Kommentar eine Antwort ist.
*
* @return bool true wenn der Kommentar eine Antwort ist, sonst false
*/
public function isReply(): bool
{
return $this->parentCommentId !== null;
}
/**
* Gibt den Autor des Kommentars zurück.
*
@@ -89,4 +112,4 @@ class Comment
{
return $this->created;
}
}
}