Files
webprogrammierung/php/model/Article.php
T
niklas.ortmann c52834aa0d Article.php + getArticle Anpassungen
Article-Klasse ist nun syntaktisch korrekt.
getArticle gibt nun als Rückgabe einen Typ Article zurück
2026-05-29 09:57:50 +02:00

137 lines
2.9 KiB
PHP

<?php
/**
* Klasse: Artikel
* Diese Klasse stellt alle Daten eines Artikels (Beitrag) bereit
*
* @author Niklas Ortmann
*/
class Article
{
private $id;
private $title;
private $content;
private $author;
private $creationDate;
private $category;
private $tags;
/**
* Konstruktor
*
* @param $id integer ID des Beitrages
* @param $title string Titel des Beitrags
* @param $content string Inhalt des Beitrags
* @param $author string der Autor des des Beitrages NID
* @param $category string Kategorie des Beitrages
* @param $tags string optionale Schlagworte für eine bessere Suche
* @param $creationDate string Datum der Beitragserstellung
*/
public function __construct(int $id, string $title, string $content, string $author, string $category, string $tags, string $creationDate)
{
$this->id = $id;
$this->title = $title;
$this->content = $content;
$this->author = $author;
$this->creationDate = $creationDate;
$this->category = $category;
$this->tags = $tags;
}
/**
* Gibt die ID eines Artikels zurück.
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Gibt den Titel eines Artikels zurück.
* @return string
*/
public function getTitle(): string
{
return $this->title;
}
/**
* Setzt den Titel eines Artikels
* @param $title
* @return void
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Gibt den Content eines Artikels zurück.
* TODO: Content muss noch definiert werden.
* @return string
*/
public function getContent(): string
{
return $this->content;
}
/**
* Setzt den Content eines Artikels.
* TODO: Content muss noch definiert werden.
* @param $content
* @return void
*/
public function setContent($content)
{
$this->content = $content;
}
/**
* Gibt den Autor eines Artikels zurück.
* @return string
*/
public function getAuthor(): string
{
return $this->author;
}
/**
* Gibt das Veröffentlichungsdatum des Artikels zurück.
* @return string
*/
public function getCreationDate()
{
return $this->creationDate;
}
/**
* Gibt die Kategorie eines Artikels zurück.
* @return string
*/
public function getCategory(): string
{
return $this->category;
}
/**
* Gibt die Schlagworte eines Artikels zurück.
* @return string
*/
public function getTags(): string
{
return $this->tags;
}
/**
* Setzt die Schlagworte eines Artikels.
* @param string $tags
*/
public function setTags(string $tags)
{
$this->tags = $tags;
}
}
?>