Contact::town()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the G.L.S.R. Apps package.
7
 *
8
 * (c) Dev-Int Création <[email protected]>.
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Core\Domain\Common\Model;
15
16
use Core\Domain\Common\Model\VO\ContactAddress;
17
use Core\Domain\Common\Model\VO\ContactUuid;
18
use Core\Domain\Common\Model\VO\EmailField;
19
use Core\Domain\Common\Model\VO\NameField;
20
use Core\Domain\Common\Model\VO\PhoneField;
21
22
abstract class Contact
23
{
24
    protected string $uuid;
25
    protected string $companyName;
26
    protected string $address;
27
    protected string $zipCode;
28
    protected string $town;
29
    protected string $country;
30
    protected string $phone;
31
    protected string $facsimile;
32
    protected string $email;
33
    protected string $contactName;
34
    protected string $cellphone;
35
    protected string $slug;
36
37
    public function __construct(
38
        ContactUuid $uuid,
39
        NameField $companyName,
40
        string $address,
41
        string $zipCode,
42
        string $town,
43
        string $country,
44
        PhoneField $phone,
45
        PhoneField $facsimile,
46
        EmailField $email,
47
        string $contactName,
48
        PhoneField $cellphone
49
    ) {
50
        $this->uuid = $uuid->toString();
51
        $this->companyName = $companyName->getValue();
52
        $this->slug = $companyName->slugify();
53
        $this->address = $address;
54
        $this->zipCode = $zipCode;
55
        $this->town = $town;
56
        $this->country = $country;
57
        $this->phone = $phone->getValue();
58
        $this->facsimile = $facsimile->getValue();
59
        $this->email = $email->getValue();
60
        $this->contactName = $contactName;
61
        $this->cellphone = $cellphone->getValue();
62
    }
63
64
    public function uuid(): string
65
    {
66
        return $this->uuid;
67
    }
68
69
    public function companyName(): string
70
    {
71
        return $this->companyName;
72
    }
73
74
    public function fullAddress(): string
75
    {
76
        return ContactAddress::fromArray([$this->address, $this->zipCode, $this->town, $this->country])->getValue();
77
    }
78
79
    public function rewriteAddress(array $addressData): void
80
    {
81
        $address = ContactAddress::fromArray($addressData);
82
        $this->address = $address->address();
83
        $this->zipCode = $address->zipCode();
84
        $this->town = $address->town();
85
        $this->country = $address->country();
86
    }
87
88
    public function phone(): string
89
    {
90
        return $this->phone;
91
    }
92
93
    public function changePhoneNumber(PhoneField $phone): void
94
    {
95
        $this->phone = $phone->getValue();
96
    }
97
98
    public function facsimile(): string
99
    {
100
        return $this->facsimile;
101
    }
102
103
    public function changeFacsimileNumber(PhoneField $facsimile): void
104
    {
105
        $this->facsimile = $facsimile->getValue();
106
    }
107
108
    public function email(): string
109
    {
110
        return $this->email;
111
    }
112
113
    public function rewriteEmail(EmailField $email): void
114
    {
115
        $this->email = $email->getValue();
116
    }
117
118
    public function contactName(): string
119
    {
120
        return $this->contactName;
121
    }
122
123
    public function renameContact(string $contact): void
124
    {
125
        $this->contactName = $contact;
126
    }
127
128
    public function cellphone(): string
129
    {
130
        return $this->cellphone;
131
    }
132
133
    public function changeCellphoneNumber(PhoneField $cellphone): void
134
    {
135
        $this->cellphone = $cellphone->getValue();
136
    }
137
138
    public function slug(): string
139
    {
140
        return $this->slug;
141
    }
142
143
    public function address(): string
144
    {
145
        return $this->address;
146
    }
147
148
    public function zipCode(): string
149
    {
150
        return $this->zipCode;
151
    }
152
153
    public function town(): string
154
    {
155
        return $this->town;
156
    }
157
158
    public function country(): string
159
    {
160
        return $this->country;
161
    }
162
}
163