Completed
Pull Request — master (#1)
by Gabriel
62:08
created

Address::getFirstName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\AddressChange\Domain\Model;
6
7
class Address {
8
9
	private const TYPE_PERSONAL = 'personal';
10
11
	private const TYPE_COMPANY = 'company';
12
13
	private $id;
0 ignored issues
show
introduced by
The private property $id is not used, and could be removed.
Loading history...
14
15
	private $salutation;
16
17
	private $company;
18
19
	private $title;
20
21
	private $firstName = '';
22
23
	private $lastName = '';
24
25
	private $address;
26
27
	private $postcode;
28
29
	private $city;
30
31
	private $country = '';
32
33
	private $addressType;
34
35
	private function __construct(
36
		string $salutation,
37
		string $company,
38
		string $title,
39
		string $firstName,
40
		string $lastName,
41
		string $address,
42
		string $postcode,
43
		string $city,
44
		string $country,
45
		string $addressType ) {
46
		$this->salutation = $salutation;
47
		$this->company = $company;
48
		$this->title = $title;
49
		$this->firstName = $firstName;
50
		$this->lastName = $lastName;
51
		$this->address = $address;
52
		$this->postcode = $postcode;
53
		$this->city = $city;
54
		$this->country = $country;
55
		$this->addressType = $addressType;
56
	}
57
58
	static public function newPersonalAddress(
59
		string $salutation,
60
		string $title,
61
		string $firstName,
62
		string $lastName,
63
		string $address,
64
		string $postcode,
65
		string $city,
66
		string $country ): self {
67
		return new self( $salutation, '', $title, $firstName, $lastName, $address, $postcode, $city, $country, self::TYPE_PERSONAL );
68
	}
69
70
	static public function newCompanyAddress(
71
		string $company,
72
		string $address,
73
		string $postcode,
74
		string $city,
75
		string $country ): self {
76
		return new self( '', $company, '', '', '', $address, $postcode, $city, $country, self::TYPE_COMPANY );
77
	}
78
79
	public function isPersonalAddress(): bool {
80
		return $this->addressType === self::TYPE_PERSONAL;
81
	}
82
83
	public function isCompanyAddress(): bool {
84
		return $this->addressType === self::TYPE_COMPANY;
85
	}
86
87
	public function getSalutation(): string {
88
		return $this->salutation;
89
	}
90
91
	public function getCompany(): string {
92
		return $this->company;
93
	}
94
95
	public function getTitle(): string {
96
		return $this->title;
97
	}
98
99
	public function getFirstName(): string {
100
		return $this->firstName;
101
	}
102
103
	public function getLastName(): string {
104
		return $this->lastName;
105
	}
106
107
	public function getAddress(): string {
108
		return $this->address;
109
	}
110
111
	public function getPostcode(): string {
112
		return $this->postcode;
113
	}
114
115
	public function getCity(): string {
116
		return $this->city;
117
	}
118
119
	public function getCountry(): string {
120
		return $this->country;
121
	}
122
}
123