|
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\GeoPoint; |
|
15
|
|
|
use Daikon\ValueObject\IntValue; |
|
16
|
|
|
use Daikon\ValueObject\Text; |
|
17
|
|
|
use Daikon\ValueObject\ValueObjectInterface; |
|
18
|
|
|
|
|
19
|
|
|
final class Location extends Entity |
|
20
|
|
|
{ |
|
21
|
|
|
public static function getAttributeMap(): AttributeMap |
|
22
|
|
|
{ |
|
23
|
|
|
return new AttributeMap([ |
|
24
|
|
|
Attribute::define('id', IntValue::class), |
|
25
|
|
|
Attribute::define('name', Text::class), |
|
26
|
|
|
Attribute::define('street', Text::class), |
|
27
|
|
|
Attribute::define('postalCode', Text::class), |
|
28
|
|
|
Attribute::define('city', Text::class), |
|
29
|
|
|
Attribute::define('country', Text::class), |
|
30
|
|
|
Attribute::define('coords', GeoPoint::class) |
|
31
|
|
|
]); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function getIdentity(): ValueObjectInterface |
|
35
|
|
|
{ |
|
36
|
|
|
return $this->getId(); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function getId(): IntValue |
|
40
|
|
|
{ |
|
41
|
|
|
return $this->get('id') ?? IntValue::zero(); |
|
|
|
|
|
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function getName(): Text |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->get('name') ?? Text::makeEmpty(); |
|
|
|
|
|
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function getStreet(): Text |
|
50
|
|
|
{ |
|
51
|
|
|
return $this->get('street') ?? Text::makeEmpty(); |
|
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function getPostalCode(): Text |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->get('postalCode') ?? Text::makeEmpty(); |
|
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function getCity(): Text |
|
60
|
|
|
{ |
|
61
|
|
|
return $this->get('city') ?? Text::makeEmpty(); |
|
|
|
|
|
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function getCountry(): Text |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->get('country') ?? Text::makeEmpty(); |
|
|
|
|
|
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function getCoords(): ?GeoPoint |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->get('coords'); |
|
|
|
|
|
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|