Implementierung
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @author Caroline Schulte
|
||||
*/
|
||||
class Comment
|
||||
{
|
||||
private int $id;
|
||||
private int $articleId;
|
||||
private string $author;
|
||||
private string $content;
|
||||
private string $created;
|
||||
|
||||
/**
|
||||
* Erstellt einen neuen Kommentar.
|
||||
*
|
||||
* @param int $id Eindeutige ID des Kommentars
|
||||
* @param int $articleId ID des zugehörigen Beitrags
|
||||
* @param string $author Autor des Kommentars
|
||||
* @param string $content Inhalt des Kommentars
|
||||
* @param string $created Erstellungsdatum des Kommentars
|
||||
*/
|
||||
public function __construct(
|
||||
int $id,
|
||||
int $articleId,
|
||||
string $author,
|
||||
string $content,
|
||||
string $created
|
||||
) {
|
||||
$this->id = $id;
|
||||
$this->articleId = $articleId;
|
||||
$this->author = $author;
|
||||
$this->content = $content;
|
||||
$this->created = $created;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt die ID des Kommentars zurück.
|
||||
*
|
||||
* @return int Kommentar-ID
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt die ID des zugehörigen Beitrags zurück.
|
||||
*
|
||||
* @return int Beitrags-ID
|
||||
*/
|
||||
public function getArticleId(): int
|
||||
{
|
||||
return $this->articleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt den Autor des Kommentars zurück.
|
||||
*
|
||||
* @return string Autor
|
||||
*/
|
||||
public function getAuthor(): string
|
||||
{
|
||||
return $this->author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt den Inhalt des Kommentars zurück.
|
||||
*
|
||||
* @return string Kommentarinhalt
|
||||
*/
|
||||
public function getContent(): string
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt das Erstellungsdatum des Kommentars zurück.
|
||||
*
|
||||
* @return string Erstellungsdatum
|
||||
*/
|
||||
public function getCreated(): string
|
||||
{
|
||||
return $this->created;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user