Passed
Push — main ( 5489db...717dd1 )
by Vasil
15:04
created

ShipmentSender::setClientId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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 int|null
26
     * @Serializer\Type("integer")
27
     */
28
    private ?int $clientId = null;
29
30
    /**
31
     * @var ShipmentPhoneNumber
32
     */
33
    private ShipmentPhoneNumber $phone1;
34
35
    /**
36
     * @var ?ShipmentPhoneNumber
37
     */
38
    private ?ShipmentPhoneNumber $phone2 = null;
39
40
    /**
41
     * @var ?ShipmentPhoneNumber
42
     */
43
    private ?ShipmentPhoneNumber $phone3 = null;
44
45
    /**
46
     * @var string|null
47
     * @Serializer\Type("string")
48
     */
49
    private ?string $clientName = null;
50
51
    /**
52
     * @var string|null
53
     * @Serializer\Type("string")
54
     */
55
    private ?string $contactName = null;
56
57
    /**
58
     * @var string|null
59
     * @Serializer\Type("string")
60
     */
61
    private ?string $email = null;
62
63
    /**
64
     * @var bool
65
     * @Serializer\Type("bool")
66
     */
67
    private bool $privatePerson = true;
68
69
    /**
70
     * @var ?ShipmentAddress
71
     */
72
    private ?ShipmentAddress $address = null;
73
74
    /**
75
     * @var int
76
     * @Serializer\Type("integer")
77
     */
78
    private ?int $dropoffOfficeId = null;
79
80
81 12
    public function __construct(
82
        ShipmentPhoneNumber $phone1,
83
        string $email,
84
        string $clientName,
85
        int $dropoffOfficeId = null,
86
    ) {
87 12
        $this->phone1 = $phone1;
88 12
        $this->email = $email;
89 12
        $this->clientName = $clientName;
90 12
        $this->dropoffOfficeId = $dropoffOfficeId;
91
    }
92
93
    /**
94
     * @return ShipmentPhoneNumber
95
     */
96 1
    public function getPhone1(): ShipmentPhoneNumber
97
    {
98 1
        return $this->phone1;
99
    }
100
101
    /**
102
     * @param ShipmentPhoneNumber $phone1
103
     */
104 4
    public function setPhone1(ShipmentPhoneNumber $phone1): void
105
    {
106 4
        $this->phone1 = $phone1;
107
    }
108
109
    /**
110
     * @return ShipmentPhoneNumber
111
     */
112 1
    public function getPhone2(): ShipmentPhoneNumber
113
    {
114 1
        return $this->phone2;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->phone2 could return the type null which is incompatible with the type-hinted return VasilDakov\Speedy\Servic...ent\ShipmentPhoneNumber. Consider adding an additional type-check to rule them out.
Loading history...
115
    }
116
117
    /**
118
     * @param ShipmentPhoneNumber $phone2
119
     */
120 1
    public function setPhone2(ShipmentPhoneNumber $phone2): void
121
    {
122 1
        $this->phone2 = $phone2;
123
    }
124
125
    /**
126
     * @return ShipmentPhoneNumber
127
     */
128 1
    public function getPhone3(): ShipmentPhoneNumber
129
    {
130 1
        return $this->phone3;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->phone3 could return the type null which is incompatible with the type-hinted return VasilDakov\Speedy\Servic...ent\ShipmentPhoneNumber. Consider adding an additional type-check to rule them out.
Loading history...
131
    }
132
133
    /**
134
     * @param ShipmentPhoneNumber $phone3
135
     */
136 1
    public function setPhone3(ShipmentPhoneNumber $phone3): void
137
    {
138 1
        $this->phone3 = $phone3;
139
    }
140
141
    /**
142
     * @return string|null
143
     */
144 1
    public function getClientName(): ?string
145
    {
146 1
        return $this->clientName;
147
    }
148
149
    /**
150
     * @param string $clientName
151
     */
152 1
    public function setClientName(string $clientName): void
153
    {
154 1
        $this->clientName = $clientName;
155
    }
156
157
    /**
158
     * @return string
159
     */
160 1
    public function getContactName(): string
161
    {
162 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...
163
    }
164
165
    /**
166
     * @param string $contactName
167
     */
168 4
    public function setContactName(string $contactName): void
169
    {
170 4
        $this->contactName = $contactName;
171
    }
172
173
    /**
174
     * @return string
175
     */
176 1
    public function getEmail(): string
177
    {
178 1
        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...
179
    }
180
181
    /**
182
     * @param string $email
183
     */
184 4
    public function setEmail(string $email): void
185
    {
186 4
        $this->email = $email;
187
    }
188
189
    /**
190
     * @return bool
191
     */
192 1
    public function isPrivatePerson(): bool
193
    {
194 1
        return $this->privatePerson;
195
    }
196
197
    /**
198
     * @param bool $privatePerson
199
     */
200 1
    public function setPrivatePerson(bool $privatePerson): void
201
    {
202 1
        $this->privatePerson = $privatePerson;
203
    }
204
205
    /**
206
     * @return ShipmentAddress
207
     */
208 1
    public function getAddress(): ShipmentAddress
209
    {
210 1
        return $this->address;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->address could return the type null which is incompatible with the type-hinted return VasilDakov\Speedy\Service\Shipment\ShipmentAddress. Consider adding an additional type-check to rule them out.
Loading history...
211
    }
212
213
    /**
214
     * @param ShipmentAddress $address
215
     */
216 1
    public function setAddress(ShipmentAddress $address): void
217
    {
218 1
        $this->address = $address;
219
    }
220
221
    /**
222
     * @return int
223
     */
224 1
    public function getDropoffOfficeId(): int
225
    {
226 1
        return $this->dropoffOfficeId;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->dropoffOfficeId could return the type null which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
227
    }
228
229
    /**
230
     * @param int $dropoffOfficeId
231
     */
232 1
    public function setDropoffOfficeId(int $dropoffOfficeId): void
233
    {
234 1
        $this->dropoffOfficeId = $dropoffOfficeId;
235
    }
236
237
    /**
238
     * @param int|null $clientId
239
     */
240
    public function setClientId(?int $clientId): void
241
    {
242
        $this->clientId = $clientId;
243
    }
244
245
    /**
246
     * @return int|null
247
     */
248
    public function getClientId(): ?int
249
    {
250
        return $this->clientId;
251
    }
252
253 3
    public function toArray(): array
254
    {
255 3
        return [
256 3
            Speedy::PHONE_1 => $this->phone1->toArray(),
257 3
            Speedy::CONTACT_NAME => $this->contactName,
258 3
            Speedy::EMAIL => $this->email,
259 3
        ];
260
    }
261
262
}
263