|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Application\Traits; |
|
6
|
|
|
|
|
7
|
|
|
use Application\Model\Country; |
|
8
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Common fields to represent an address. |
|
12
|
|
|
*/ |
|
13
|
|
|
trait HasAddress |
|
14
|
|
|
{ |
|
15
|
|
|
#[ORM\Column(type: 'string', length: 191, options: ['default' => ''])] |
|
16
|
|
|
private string $firstName = ''; |
|
17
|
|
|
|
|
18
|
|
|
#[ORM\Column(type: 'string', length: 191, options: ['default' => ''])] |
|
19
|
|
|
private string $lastName = ''; |
|
20
|
|
|
|
|
21
|
|
|
#[ORM\Column(type: 'string', options: ['default' => ''])] |
|
22
|
|
|
private string $street = ''; |
|
23
|
|
|
|
|
24
|
|
|
#[ORM\Column(type: 'string', length: 20, options: ['default' => ''])] |
|
25
|
|
|
private string $postcode = ''; |
|
26
|
|
|
|
|
27
|
|
|
#[ORM\Column(type: 'string', length: 255, options: ['default' => ''])] |
|
28
|
|
|
private string $locality = ''; |
|
29
|
|
|
|
|
30
|
|
|
#[ORM\ManyToOne(targetEntity: Country::class)] |
|
31
|
|
|
#[ORM\JoinColumn(onDelete: 'SET NULL')] |
|
32
|
|
|
private ?Country $country = null; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Set first name. |
|
36
|
|
|
* |
|
37
|
|
|
* @param string $firstName |
|
38
|
|
|
*/ |
|
39
|
16 |
|
public function setFirstName($firstName): void |
|
40
|
|
|
{ |
|
41
|
16 |
|
$this->firstName = $firstName; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Get first name. |
|
46
|
|
|
*/ |
|
47
|
14 |
|
public function getFirstName(): string |
|
48
|
|
|
{ |
|
49
|
14 |
|
return (string) $this->firstName; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Set last name. |
|
54
|
|
|
* |
|
55
|
|
|
* @param string $lastName |
|
56
|
|
|
*/ |
|
57
|
16 |
|
public function setLastName($lastName): void |
|
58
|
|
|
{ |
|
59
|
16 |
|
$this->lastName = $lastName; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Get last name. |
|
64
|
|
|
*/ |
|
65
|
14 |
|
public function getLastName(): string |
|
66
|
|
|
{ |
|
67
|
14 |
|
return (string) $this->lastName; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
5 |
|
public function getStreet(): string |
|
71
|
|
|
{ |
|
72
|
5 |
|
return $this->street; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
15 |
|
public function setStreet(string $street): void |
|
76
|
|
|
{ |
|
77
|
15 |
|
$this->street = $street; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
5 |
|
public function getPostcode(): string |
|
81
|
|
|
{ |
|
82
|
5 |
|
return $this->postcode; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
15 |
|
public function setPostcode(string $postcode): void |
|
86
|
|
|
{ |
|
87
|
15 |
|
$this->postcode = $postcode; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
5 |
|
public function getLocality(): string |
|
91
|
|
|
{ |
|
92
|
5 |
|
return $this->locality; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
15 |
|
public function setLocality(string $locality): void |
|
96
|
|
|
{ |
|
97
|
15 |
|
$this->locality = $locality; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
5 |
|
public function getCountry(): ?Country |
|
101
|
|
|
{ |
|
102
|
5 |
|
return $this->country; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
15 |
|
public function setCountry(?Country $country = null): void |
|
106
|
|
|
{ |
|
107
|
15 |
|
$this->country = $country; |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|