-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathVideo.php
More file actions
77 lines (63 loc) · 1.61 KB
/
Video.php
File metadata and controls
77 lines (63 loc) · 1.61 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
<?php
declare(strict_types=1);
namespace CodelyTv\Mooc\Videos\Domain;
use CodelyTv\Mooc\Shared\Domain\Courses\CourseId;
use CodelyTv\Mooc\Shared\Domain\Videos\VideoUrl;
use CodelyTv\Shared\Domain\Aggregate\AggregateRoot;
use DateTimeImmutable;
final class Video extends AggregateRoot
{
private DateTimeImmutable $created;
public function __construct(
private readonly VideoId $id,
private readonly VideoType $type,
private VideoTitle $title,
private readonly VideoUrl $url,
private readonly CourseId $courseId
) {
$this->created = new DateTimeImmutable();
}
public static function create(
VideoId $id,
VideoType $type,
VideoTitle $title,
VideoUrl $url,
CourseId $courseId
): Video {
$video = new self($id, $type, $title, $url, $courseId);
$video->record(
new VideoCreatedDomainEvent(
$id->value(),
$type->value(),
$title->value(),
$url->value(),
$courseId->value()
)
);
return $video;
}
public function updateTitle(VideoTitle $newTitle): void
{
$this->title = $newTitle;
}
public function id(): VideoId
{
return $this->id;
}
public function type(): VideoType
{
return $this->type;
}
public function title(): VideoTitle
{
return $this->title;
}
public function url(): VideoUrl
{
return $this->url;
}
public function courseId(): CourseId
{
return $this->courseId;
}
}