| 1 | <?php |
||
| 20 | final class PostViewModel |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | private $id; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var string |
||
| 29 | */ |
||
| 30 | private $title; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var string |
||
| 34 | */ |
||
| 35 | private $slug; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var string |
||
| 39 | */ |
||
| 40 | private $summary; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @var string |
||
| 44 | */ |
||
| 45 | private $content; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @var DateTimeInterface |
||
| 49 | */ |
||
| 50 | private $publishedAt; |
||
| 51 | |||
| 52 | private function __construct( |
||
| 53 | string $id, |
||
| 54 | string $title, |
||
| 55 | string $slug, |
||
| 56 | string $summary, |
||
| 57 | string $content, |
||
| 58 | DateTimeInterface $publishedAt |
||
| 59 | ) { |
||
| 60 | $this->id = $id; |
||
| 61 | $this->title = $title; |
||
| 62 | $this->slug = $slug; |
||
| 63 | $this->summary = $summary; |
||
| 64 | $this->content = $content; |
||
| 65 | $this->publishedAt = $publishedAt; |
||
| 66 | } |
||
| 67 | |||
| 68 | public static function constructFromEntity(Post $post): self |
||
| 79 | |||
| 80 | public function getId(): string |
||
| 84 | |||
| 85 | public function getTitle(): string |
||
| 89 | |||
| 90 | public function getSlug(): string |
||
| 94 | |||
| 95 | public function getSummary(): string |
||
| 99 | |||
| 100 | public function getContent(): string |
||
| 104 | |||
| 105 | public function getPublishedAt(): DateTimeInterface |
||
| 109 | } |
||
| 110 |