Passed
Push — main ( 8bdffa...c425e9 )
by Vasil
04:29
created

CreateShipmentRequest::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 8
ccs 7
cts 7
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VasilDakov\Speedy\Shipment;
6
7
use VasilDakov\Speedy\Speedy;
8
use InvalidArgumentException;
9
use JMS\Serializer\Annotation as Serializer;
10
11
use function strlen;
12
13
/**
14
 * Class CreateShipmentRequest
15
 *
16
 * @Serializer\AccessType("public_method")
17
 * @author Valentin Valkanov <[email protected]>
18
 * @author Vasil Dakov <[email protected]>
19
 * @copyright
20
 * @version
21
 */
22
class CreateShipmentRequest
23
{
24
    /**
25
     * @var ShipmentRecipient
26
     * @Serializer\Type("VasilDakov\Speedy\Shipment\ShipmentRecipient")
27
     */
28
    private ShipmentRecipient $recipient;
29
30
    /**
31
     * @var ShipmentService
32
     * @Serializer\Type("VasilDakov\Speedy\Shipment\ShipmentService")
33
     */
34
    private ShipmentService $service;
35
36
    /**
37
     * @var ShipmentContent
38
     * @Serializer\Type("VasilDakov\Speedy\Shipment\ShipmentContent")
39
     */
40
    private ShipmentContent $content;
41
42
    /**
43
     * @var ShipmentPayment
44
     * @Serializer\Type("VasilDakov\Speedy\Shipment\ShipmentPayment")
45
     */
46
    private ShipmentPayment $payment;
47
48
    /**
49
     * @var ShipmentSender
50
     * @Serializer\Type("VasilDakov\Speedy\Shipment\ShipmentSender")
51
     */
52
    private ShipmentSender $sender;
53
54
    /**
55
     * @var string|null
56
     * @Serializer\Type("string")
57
     */
58
    private ?string $shipmentNote;
59
60
    /**
61
     * @var string|null
62
     * @Serializer\Type("string")
63
     */
64
    private ?string $ref1;
65
66
    /**
67
     * @var string|null
68
     * @Serializer\Type("string")
69
     */
70
    private ?string $ref2;
71
72
    /**
73
     * @var string|null
74
     * @Serializer\Type("string")
75
     */
76
    private ?string $consolidationRef;
77
78
    /**
79
     * @var bool
80
     * @Serializer\Type("bool")
81
     */
82
    private bool $requireUnsuccessfulDeliveryStickerImage = false;
83
84
    /**
85
     * @param ShipmentSender $sender
86
     * @param ShipmentRecipient $recipient
87
     * @param ShipmentService $service
88
     * @param ShipmentContent $content
89
     * @param ShipmentPayment $payment
90
     */
91 13
    public function __construct(
92
        ShipmentSender $sender,
93
        ShipmentRecipient $recipient,
94
        ShipmentService $service,
95
        ShipmentContent $content,
96
        ShipmentPayment $payment
97
    ) {
98 13
        $this->setSender($sender);
99 13
        $this->setRecipient($recipient);
100 13
        $this->setService($service);
101 13
        $this->setContent($content);
102 13
        $this->setPayment($payment);
103
    }
104
105
    /**
106
     * @return ShipmentRecipient
107
     */
108 2
    public function getRecipient(): ShipmentRecipient
109
    {
110 2
        return $this->recipient;
111
    }
112
113
    /**
114
     * @param ShipmentRecipient $recipient
115
     * @return void
116
     */
117 15
    public function setRecipient(ShipmentRecipient $recipient): void
118
    {
119 15
        $this->recipient = $recipient;
120
    }
121
122
    /**
123
     * @return ShipmentService
124
     */
125 2
    public function getService(): ShipmentService
126
    {
127 2
        return $this->service;
128
    }
129
130
    /**
131
     * @param ShipmentService $service
132
     * @return void
133
     */
134 15
    public function setService(ShipmentService $service): void
135
    {
136 15
        $this->service = $service;
137
    }
138
139
    /**
140
     * @return ShipmentContent
141
     */
142 2
    public function getContent(): ShipmentContent
143
    {
144 2
        return $this->content;
145
    }
146
147
    /**
148
     * @param ShipmentContent $content
149
     * @return void
150
     */
151 15
    public function setContent(ShipmentContent $content): void
152
    {
153 15
        $this->content = $content;
154
    }
155
156
    /**
157
     * @return ShipmentPayment
158
     */
159 2
    public function getPayment(): ShipmentPayment
160
    {
161 2
        return $this->payment;
162
    }
163
164
    /**
165
     * @param ShipmentPayment $payment
166
     * @return void
167
     */
168 15
    public function setPayment(ShipmentPayment $payment): void
169
    {
170 15
        $this->payment = $payment;
171
    }
172
173
    /**
174
     * @return ShipmentSender
175
     */
176 1
    public function getSender(): ShipmentSender
177
    {
178 1
        return $this->sender;
179
    }
180
181
    /**
182
     * @param ShipmentSender $sender
183
     * @return $this
184
     */
185 13
    public function setSender(ShipmentSender $sender): self
186
    {
187 13
        $this->sender = $sender;
188
189 13
        return $this;
190
    }
191
192
    /**
193
     * @return string|null
194
     */
195 1
    public function getShipmentNote(): ?string
196
    {
197 1
        return $this->shipmentNote;
198
    }
199
200
    /**
201
     * @param string $shipmentNote
202
     * @return $this
203
     */
204 3
    public function setShipmentNote(string $shipmentNote): self
205
    {
206 3
        $this->shipmentNote = $shipmentNote;
207
208 3
        return $this;
209
    }
210
211
    /**
212
     * @return string|null
213
     */
214 1
    public function getRef1(): ?string
215
    {
216 1
        return $this->ref1;
217
    }
218
219
    /**
220
     * @param string $ref1
221
     * @return $this
222
     */
223 3
    public function setRef1(string $ref1): self
224
    {
225 3
        $this->ref1 = $ref1;
226
227 3
        return $this;
228
    }
229
230
    /**
231
     * @return string
232
     */
233 1
    public function getRef2(): ?string
234
    {
235 1
        return $this->ref2;
236
    }
237
238
    /**
239
     * @param string $ref2
240
     * @return $this
241
     */
242 3
    public function setRef2(string $ref2): ?self
243
    {
244 3
        $this->ref2 = $ref2;
245
246 3
        return $this;
247
    }
248
249
    /**
250
     * @return string|null
251
     */
252 1
    public function getConsolidationRef(): ?string
253
    {
254 1
        return $this->consolidationRef;
255
    }
256
257
    /**
258
     * @param ?string $consolidationRef
259
     * @return $this
260
     */
261 1
    public function setConsolidationRef(string $consolidationRef): void
262
    {
263 1
        $this->consolidationRef = $consolidationRef;
264
    }
265
266
    /**
267
     * @return bool
268
     */
269 1
    public function getRequireUnsuccessfulDeliveryStickerImage(): bool
270
    {
271 1
        return $this->requireUnsuccessfulDeliveryStickerImage;
272
    }
273
274
    /**
275
     * @param bool $requireUnsuccessfulDeliveryStickerImage
276
     * @return $this
277
     */
278 1
    public function setRequireUnsuccessfulDeliveryStickerImage(bool $requireUnsuccessfulDeliveryStickerImage): self
279
    {
280 1
        $this->requireUnsuccessfulDeliveryStickerImage = $requireUnsuccessfulDeliveryStickerImage;
281
282 1
        return $this;
283
    }
284
285
    /**
286
     * @return array
287
     */
288 2
    public function toArray(): array
289
    {
290 2
        return [
291 2
            Speedy::SENDER        => $this->sender->toArray(),
292 2
            Speedy::RECIPIENT     => $this->recipient->toArray(),
293 2
            Speedy::SERVICE       => $this->service->toArray(),
294 2
            Speedy::CONTENT       => $this->content->toArray(),
295 2
            Speedy::PAYMENT       => $this->payment->toArray(),
296 2
            //Speedy::SHIPMENT_NOTE => $this->getShipmentNote(),
297 2
            //Speedy::REF_1         => $this->getRef1(),
298 2
            //Speedy::REF_2         => $this->getRef2(),
299 2
            //Speedy::CONSOLIDATION_REF => '',
300 2
            //Speedy::REQUIRE_UNSUCCESSFUL_DELIVERY_STICKER_IMAGE => '',
301 2
        ];
302
    }
303
}
304