|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the daikon-cqrs/entity project. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Daikon\Tests\Entity\Fixture; |
|
10
|
|
|
|
|
11
|
|
|
use Daikon\Entity\Attribute; |
|
12
|
|
|
use Daikon\Entity\AttributeMap; |
|
13
|
|
|
use Daikon\Entity\Entity; |
|
14
|
|
|
use Daikon\ValueObject\BoolValue; |
|
15
|
|
|
use Daikon\ValueObject\Date; |
|
16
|
|
|
use Daikon\ValueObject\Email; |
|
17
|
|
|
use Daikon\ValueObject\FloatValue; |
|
18
|
|
|
use Daikon\ValueObject\Text; |
|
19
|
|
|
use Daikon\ValueObject\Timestamp; |
|
20
|
|
|
use Daikon\ValueObject\Url; |
|
21
|
|
|
use Daikon\ValueObject\Uuid; |
|
22
|
|
|
use Daikon\ValueObject\ValueObjectInterface; |
|
23
|
|
|
|
|
24
|
|
|
final class Article extends Entity |
|
25
|
|
|
{ |
|
26
|
|
|
public static function getAttributeMap(): AttributeMap |
|
27
|
|
|
{ |
|
28
|
|
|
return new AttributeMap([ |
|
29
|
|
|
Attribute::define('id', Uuid::class), |
|
30
|
|
|
Attribute::define('created', Timestamp::class), |
|
31
|
|
|
Attribute::define('title', Text::class), |
|
32
|
|
|
Attribute::define('url', Url::class), |
|
33
|
|
|
Attribute::define('feedbackMail', Email::class), |
|
34
|
|
|
Attribute::define('averageVoting', FloatValue::class), |
|
35
|
|
|
Attribute::define('workshopDate', Date::class), |
|
36
|
|
|
Attribute::define('workshopCancelled', BoolValue::class), |
|
37
|
|
|
Attribute::define('workshopLocation', Location::class), |
|
38
|
|
|
Attribute::define('paragraphs', ParagraphList::class) |
|
39
|
|
|
]); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function getIdentity(): ValueObjectInterface |
|
43
|
|
|
{ |
|
44
|
|
|
return $this->getId(); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function getId(): Uuid |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->get('id') ?? Uuid::generate(); |
|
|
|
|
|
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function getTitle(): Text |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->get('title') ?? Text::makeEmpty(); |
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function getUrl(): ?Url |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->get('url'); |
|
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function getFeedbackMail(): ?Email |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->get('feedbackMail'); |
|
|
|
|
|
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function getAverageVoting(): ?FloatValue |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->get('averageVoting'); |
|
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function getWorkshopDate(): Date |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->get('workshopDate') ?? Date::makeEmpty(); |
|
|
|
|
|
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function getWorkshopLocation(): ?Location |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->get('workshopLocation'); |
|
|
|
|
|
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function isWorkshopCancelled(): BoolValue |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->get('workshopCancelled') ?? BoolValue::false(); |
|
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function getParagraphs(): ParagraphList |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->get('paragraphs') ?? ParagraphList::makeEmpty(); |
|
|
|
|
|
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|