33 lines
603 B
PHP
33 lines
603 B
PHP
<?php
|
|
namespace Blog\Entity;
|
|
|
|
class Post {
|
|
public function __construct(
|
|
private int $id,
|
|
private string $title,
|
|
private string $content,
|
|
private string $author,
|
|
private int $stamp
|
|
) {}
|
|
|
|
public function getId() {
|
|
return $this->id;
|
|
}
|
|
|
|
public function getTitle() {
|
|
return $this->title;
|
|
}
|
|
|
|
public function getContent($maxlength = null) {
|
|
return $maxlength ? mb_strimwidth($this->content, 0, $maxlength, "...") : $this->content;
|
|
}
|
|
|
|
public function getAuthor() {
|
|
return $this->author;
|
|
}
|
|
|
|
public function getDateTime() {
|
|
return $this->stamp;
|
|
}
|
|
}
|