first commit
This commit is contained in:
32
app/Entity/post.php
Normal file
32
app/Entity/post.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user