This repository was archived by the owner on Jun 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPost.php
More file actions
119 lines (107 loc) · 2.32 KB
/
Post.php
File metadata and controls
119 lines (107 loc) · 2.32 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
namespace Kuriv\PHPDesignPatterns\More\Repository;
class Post
{
/**
* Store the ID instance.
*
* @var PostID
*/
private PostID $id;
/**
* Store the title.
*
* @var string
*/
private string $title;
/**
* Store the content.
*
* @var string
*/
private string $content;
/**
* Store the status instance.
*
* @var PostStatus
*/
private PostStatus $status;
/**
* Store the ID instance, title, content and status instance to the current instance.
*
* @param PostID $id
* @param string $title
* @param string $content
* @param PostStatus $status
* @return void
*/
private function __construct(PostID $id, string $title, string $content, PostStatus $status)
{
$this->id = $id;
$this->title = $title;
$this->content = $content;
$this->status = $status;
}
/**
* Get the instance of the draft.
*
* @param PostID $id
* @param string $title
* @param string $content
* @return Post
*/
public static function draft(PostID $id, string $title, string $content): Post
{
return new self($id, $title, $content, PostStatus::getInstanceByStatusString(PostStatus::STATUS_DRAFT));
}
/**
* Get the created instance.
*
* @param array $array
* @return Post
*/
public static function getInstance(array $array): Post
{
return new self(PostID::getInstance($array['id']), $array['title'], $array['content'], PostStatus::getInstanceByStatusID($array['status_id']));
}
/**
* Get the ID instance.
*
* @param void
* @return PostID
*/
public function getID(): PostID
{
return $this->id;
}
/**
* Get the title.
*
* @param void
* @return string
*/
public function getTitle(): string
{
return $this->title;
}
/**
* Get the content.
*
* @param void
* @return string
*/
public function getContent(): string
{
return $this->content;
}
/**
* Get the status instance.
*
* @param void
* @return PostStatus
*/
public function getStatus(): PostStatus
{
return $this->status;
}
}