-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBlogPost.php
More file actions
62 lines (50 loc) · 1.25 KB
/
BlogPost.php
File metadata and controls
62 lines (50 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace Solid\App\BlogPost\Domain\Model;
use DateTimeImmutable;
final class BlogPost
{
private DateTimeImmutable $createdAt;
private ?DateTimeImmutable $updatedAt = null;
public function __construct(
private int $id,
private string $author,
private string $title,
private string $content,
) {
$this->createdAt = new DateTimeImmutable();
}
public function update(
?string $author = null,
?string $title = null,
?string $content = null,
): void {
$this->author = $author ?? $this->author;
$this->title = $title ?? $this->title;
$this->content = $content ?? $this->content;
$this->updatedAt = new DateTimeImmutable();
}
public function getId(): int
{
return $this->id;
}
public function getAuthor(): string
{
return $this->author;
}
public function getTitle(): string
{
return $this->title;
}
public function getContent(): string
{
return $this->content;
}
public function getCreatedAt(): DateTimeImmutable
{
return $this->createdAt;
}
public function getUpdatedAt(): ?DateTimeImmutable
{
return $this->updatedAt;
}
}