Passed
Push — main ( 7189b9...23cbe4 )
by Vasil
03:17
created

ShipmentSender   A

Complexity

Total Complexity 20

Size/Duplication

Total Lines 226
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 36
dl 0
loc 226
ccs 45
cts 45
cp 1
rs 10
c 0
b 0
f 0
wmc 20

20 Methods

Rating   Name   Duplication   Size   Complexity  
A setAddress() 0 3 1
A setContactName() 0 3 1
A getAddress() 0 3 1
A setPhone1() 0 3 1
A getDropoffOfficeId() 0 3 1
A getPhone1() 0 3 1
A setPhone2() 0 3 1
A getPhone3() 0 3 1
A getClientName() 0 3 1
A setPrivatePerson() 0 3 1
A getEmail() 0 3 1
A getContactName() 0 3 1
A toArray() 0 9 1
A setClientName() 0 3 1
A isPrivatePerson() 0 3 1
A setPhone3() 0 3 1
A getPhone2() 0 3 1
A __construct() 0 8 1
A setDropoffOfficeId() 0 3 1
A setEmail() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VasilDakov\Speedy\Service\Shipment;
6
7
use VasilDakov\Speedy\Speedy;
8
use JMS\Serializer\Annotation as Serializer;
9
use VasilDakov\Speedy\Traits\ToArray;
10
11
/**
12
 * Class ShipmentSender
13
 *
14
 * @author Valentin Valkanov <[email protected]>
15
 * @author Vasil Dakov <[email protected]>
16
 * @copyright
17
 * @version
18
 * @Serializer\AccessType("public_method")
19
 */
20
class ShipmentSender
21
{
22
    use ToArray;
23
24
    /**
25
     * @var ShipmentPhoneNumber
26
     */
27
    private ShipmentPhoneNumber $phone1;
28
29
    /**
30
     * @var ShipmentPhoneNumber
31
     */
32
    private ShipmentPhoneNumber $phone2;
33
34
    /**
35
     * @var ShipmentPhoneNumber
36
     */
37
    private ShipmentPhoneNumber $phone3;
38
39
    /**
40
     * @var string|null
41
     * @Serializer\Type("string")
42
     */
43
    private ?string $clientName = null;
44
45
    /**
46
     * @var string|null
47
     * @Serializer\Type("string")
48
     */
49
    private ?string $contactName = null;
50
51
    /**
52
     * @var string|null
53
     * @Serializer\Type("string")
54
     */
55
    private ?string $email = null;
56
57
    /**
58
     * @var bool
59
     * @Serializer\Type("bool")
60
     */
61
    private bool $privatePerson = false;
62
63
    /**
64
     * @var ShipmentAddress
65
     */
66
    private ShipmentAddress $address;
67
68
    /**
69
     * @var int
70
     * @Serializer\Type("integer")
71
     */
72
    private int $dropoffOfficeId;
73
74
    /**
75
     * @param ShipmentPhoneNumber $phone1
76
     * @param string $email
77
     * @param string $clientName
78
     */
79 12
    public function __construct(
80
        ShipmentPhoneNumber $phone1,
81
        string $email,
82
        string $clientName
83
    ) {
84 12
        $this->setPhone1($phone1);
85 12
        $this->setEmail($email);
86 12
        $this->setClientName($clientName);
87
    }
88
89
    /**
90
     * @return ShipmentPhoneNumber
91
     */
92 1
    public function getPhone1(): ShipmentPhoneNumber
93
    {
94 1
        return $this->phone1;
95
    }
96
97
    /**
98
     * @param ShipmentPhoneNumber $phone1
99
     */
100 15
    public function setPhone1(ShipmentPhoneNumber $phone1): void
101
    {
102 15
        $this->phone1 = $phone1;
103
    }
104
105
    /**
106
     * @return ShipmentPhoneNumber
107
     */
108 1
    public function getPhone2(): ShipmentPhoneNumber
109
    {
110 1
        return $this->phone2;
111
    }
112
113
    /**
114
     * @param ShipmentPhoneNumber $phone2
115
     */
116 1
    public function setPhone2(ShipmentPhoneNumber $phone2): void
117
    {
118 1
        $this->phone2 = $phone2;
119
    }
120
121
    /**
122
     * @return ShipmentPhoneNumber
123
     */
124 1
    public function getPhone3(): ShipmentPhoneNumber
125
    {
126 1
        return $this->phone3;
127
    }
128
129
    /**
130
     * @param ShipmentPhoneNumber $phone3
131
     */
132 1
    public function setPhone3(ShipmentPhoneNumber $phone3): void
133
    {
134 1
        $this->phone3 = $phone3;
135
    }
136
137
    /**
138
     * @return string|null
139
     */
140 4
    public function getClientName(): ?string
141
    {
142 4
        return $this->clientName;
143
    }
144
145
    /**
146
     * @param string $clientName
147
     */
148 12
    public function setClientName(string $clientName): void
149
    {
150 12
        $this->clientName = $clientName;
151
    }
152
153
    /**
154
     * @return string
155
     */
156 1
    public function getContactName(): string
157
    {
158 1
        return $this->contactName;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->contactName could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
159
    }
160
161
    /**
162
     * @param string $contactName
163
     */
164 4
    public function setContactName(string $contactName): void
165
    {
166 4
        $this->contactName = $contactName;
167
    }
168
169
    /**
170
     * @return string
171
     */
172 4
    public function getEmail(): string
173
    {
174 4
        return $this->email;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->email could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
175
    }
176
177
    /**
178
     * @param string $email
179
     */
180 15
    public function setEmail(string $email): void
181
    {
182 15
        $this->email = $email;
183
    }
184
185
    /**
186
     * @return bool
187
     */
188 1
    public function isPrivatePerson(): bool
189
    {
190 1
        return $this->privatePerson;
191
    }
192
193
    /**
194
     * @param bool $privatePerson
195
     */
196 1
    public function setPrivatePerson(bool $privatePerson): void
197
    {
198 1
        $this->privatePerson = $privatePerson;
199
    }
200
201
    /**
202
     * @return ShipmentAddress
203
     */
204 1
    public function getAddress(): ShipmentAddress
205
    {
206 1
        return $this->address;
207
    }
208
209
    /**
210
     * @param ShipmentAddress $address
211
     */
212 1
    public function setAddress(ShipmentAddress $address): void
213
    {
214 1
        $this->address = $address;
215
    }
216
217
    /**
218
     * @return int
219
     */
220 1
    public function getDropoffOfficeId(): int
221
    {
222 1
        return $this->dropoffOfficeId;
223
    }
224
225
    /**
226
     * @param int $dropoffOfficeId
227
     */
228 1
    public function setDropoffOfficeId(int $dropoffOfficeId): void
229
    {
230 1
        $this->dropoffOfficeId = $dropoffOfficeId;
231
    }
232
233
234
    /**
235
     * @return array
236
     */
237 3
    public function toArray(): array
238
    {
239 3
        return [
240 3
           Speedy::PHONE_1             => $this->phone1->toArray(),
241
           //Speedy::PHONE_2             => $this->phone2->toArray(),
242
           //Speedy::PHONE_3             => $this->phone3->toArray(),
243 3
           Speedy::CLIENT_NAME         => $this->getClientName(),
244
           //Speedy::CONTACT_NAME      => $this->getContactName(),
245 3
           Speedy::EMAIL               => $this->getEmail(),
246 3
           //Speedy::PRIVATE_PERSON    => $this->getPrivatePerson(),
247 3
           //Speedy::ADDRESS           => $this->getAddress(),
248 3
           //Speedy::PICKUP_OFFICE_ID  => $this->getPickupOfficeId(),
249 3
        ];
250
    }
251
}
252