Passed
Push — develop ( 1795ba...79eaf3 )
by Jens
25:35 queued 03:06
created

OrdersActionBuilder::setStore()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Commercetools\Core\Builder\Update;
4
5
use Commercetools\Core\Error\InvalidArgumentException;
6
use Commercetools\Core\Request\AbstractAction;
7
use Commercetools\Core\Request\Orders\Command\OrderAddDeliveryAction;
8
use Commercetools\Core\Request\Orders\Command\OrderAddItemShippingAddressAction;
9
use Commercetools\Core\Request\Orders\Command\OrderAddParcelToDeliveryAction;
10
use Commercetools\Core\Request\Orders\Command\OrderAddPaymentAction;
11
use Commercetools\Core\Request\Orders\Command\OrderAddReturnInfoAction;
12
use Commercetools\Core\Request\Orders\Command\OrderChangeOrderStateAction;
13
use Commercetools\Core\Request\Orders\Command\OrderChangePaymentStateAction;
14
use Commercetools\Core\Request\Orders\Command\OrderChangeShipmentStateAction;
15
use Commercetools\Core\Request\Orders\Command\OrderImportCustomLineItemStateAction;
16
use Commercetools\Core\Request\Orders\Command\OrderImportLineItemStateAction;
17
use Commercetools\Core\Request\Orders\Command\OrderRemoveDeliveryAction;
18
use Commercetools\Core\Request\Orders\Command\OrderRemoveItemShippingAddressAction;
19
use Commercetools\Core\Request\Orders\Command\OrderRemoveParcelFromDeliveryAction;
20
use Commercetools\Core\Request\Orders\Command\OrderRemovePaymentAction;
21
use Commercetools\Core\Request\Orders\Command\OrderSetBillingAddress;
22
use Commercetools\Core\Request\Orders\Command\OrderSetBillingAddressCustomFieldAction;
23
use Commercetools\Core\Request\Orders\Command\OrderSetBillingAddressCustomTypeAction;
24
use Commercetools\Core\Request\Orders\Command\OrderSetCustomFieldAction;
25
use Commercetools\Core\Request\Orders\Command\OrderSetCustomLineItemCustomFieldAction;
26
use Commercetools\Core\Request\Orders\Command\OrderSetCustomLineItemCustomTypeAction;
27
use Commercetools\Core\Request\Orders\Command\OrderSetCustomLineItemShippingDetailsAction;
28
use Commercetools\Core\Request\Orders\Command\OrderSetCustomTypeAction;
29
use Commercetools\Core\Request\Orders\Command\OrderSetCustomerEmail;
30
use Commercetools\Core\Request\Orders\Command\OrderSetCustomerIdAction;
31
use Commercetools\Core\Request\Orders\Command\OrderSetDeliveryAddressAction;
32
use Commercetools\Core\Request\Orders\Command\OrderSetDeliveryAddressCustomFieldAction;
33
use Commercetools\Core\Request\Orders\Command\OrderSetDeliveryAddressCustomTypeAction;
34
use Commercetools\Core\Request\Orders\Command\OrderSetDeliveryItemsAction;
35
use Commercetools\Core\Request\Orders\Command\OrderSetItemShippingAddressCustomFieldAction;
36
use Commercetools\Core\Request\Orders\Command\OrderSetItemShippingAddressCustomTypeAction;
37
use Commercetools\Core\Request\Orders\Command\OrderSetLineItemCustomFieldAction;
38
use Commercetools\Core\Request\Orders\Command\OrderSetLineItemCustomTypeAction;
39
use Commercetools\Core\Request\Orders\Command\OrderSetLineItemShippingDetailsAction;
40
use Commercetools\Core\Request\Orders\Command\OrderSetLocaleAction;
41
use Commercetools\Core\Request\Orders\Command\OrderSetOrderNumberAction;
42
use Commercetools\Core\Request\Orders\Command\OrderSetParcelItemsAction;
43
use Commercetools\Core\Request\Orders\Command\OrderSetParcelMeasurementsAction;
44
use Commercetools\Core\Request\Orders\Command\OrderSetParcelTrackingDataAction;
45
use Commercetools\Core\Request\Orders\Command\OrderSetReturnPaymentStateAction;
46
use Commercetools\Core\Request\Orders\Command\OrderSetReturnShipmentStateAction;
47
use Commercetools\Core\Request\Orders\Command\OrderSetShippingAddress;
48
use Commercetools\Core\Request\Orders\Command\OrderSetShippingAddressCustomFieldAction;
49
use Commercetools\Core\Request\Orders\Command\OrderSetShippingAddressCustomTypeAction;
50
use Commercetools\Core\Request\Orders\Command\OrderSetStoreAction;
51
use Commercetools\Core\Request\Orders\Command\OrderTransitionCustomLineItemStateAction;
52
use Commercetools\Core\Request\Orders\Command\OrderTransitionLineItemStateAction;
53
use Commercetools\Core\Request\Orders\Command\OrderTransitionStateAction;
54
use Commercetools\Core\Request\Orders\Command\OrderUpdateItemShippingAddressAction;
55
use Commercetools\Core\Request\Orders\Command\OrderUpdateSyncInfoAction;
56
57
class OrdersActionBuilder
58
{
59
    private $actions = [];
60
61
    /**
62
     * @link https://docs.commercetools.com/http-api-projects-orders.html#add-delivery
63
     * @param OrderAddDeliveryAction|callable $action
64
     * @return $this
65
     */
66 1
    public function addDelivery($action = null)
67
    {
68 1
        $this->addAction($this->resolveAction(OrderAddDeliveryAction::class, $action));
69 1
        return $this;
70
    }
71
72
    /**
73
     * @link https://docs.commercetools.com/http-api-projects-orders.html#add-itemshippingaddress
74
     * @param OrderAddItemShippingAddressAction|callable $action
75
     * @return $this
76
     */
77 1
    public function addItemShippingAddress($action = null)
78
    {
79 1
        $this->addAction($this->resolveAction(OrderAddItemShippingAddressAction::class, $action));
80 1
        return $this;
81
    }
82
83
    /**
84
     * @link https://docs.commercetools.com/http-api-projects-orders.html#add-parcel
85
     * @param OrderAddParcelToDeliveryAction|callable $action
86
     * @return $this
87
     */
88 1
    public function addParcelToDelivery($action = null)
89
    {
90 1
        $this->addAction($this->resolveAction(OrderAddParcelToDeliveryAction::class, $action));
91 1
        return $this;
92
    }
93
94
    /**
95
     * @link https://docs.commercetools.com/http-api-projects-orders.html#add-payment
96
     * @param OrderAddPaymentAction|callable $action
97
     * @return $this
98
     */
99 1
    public function addPayment($action = null)
100
    {
101 1
        $this->addAction($this->resolveAction(OrderAddPaymentAction::class, $action));
102 1
        return $this;
103
    }
104
105
    /**
106
     * @link https://docs.commercetools.com/http-api-projects-orders.html#addreturninfo
107
     * @param OrderAddReturnInfoAction|callable $action
108
     * @return $this
109
     */
110 1
    public function addReturnInfo($action = null)
111
    {
112 1
        $this->addAction($this->resolveAction(OrderAddReturnInfoAction::class, $action));
113 1
        return $this;
114
    }
115
116
    /**
117
     * @link https://docs.commercetools.com/http-api-projects-orders.html#change-orderstate
118
     * @param OrderChangeOrderStateAction|callable $action
119
     * @return $this
120
     */
121 1
    public function changeOrderState($action = null)
122
    {
123 1
        $this->addAction($this->resolveAction(OrderChangeOrderStateAction::class, $action));
124 1
        return $this;
125
    }
126
127
    /**
128
     * @link https://docs.commercetools.com/http-api-projects-orders.html#change-paymentstate
129
     * @param OrderChangePaymentStateAction|callable $action
130
     * @return $this
131
     */
132 1
    public function changePaymentState($action = null)
133
    {
134 1
        $this->addAction($this->resolveAction(OrderChangePaymentStateAction::class, $action));
135 1
        return $this;
136
    }
137
138
    /**
139
     * @link https://docs.commercetools.com/http-api-projects-orders.html#change-shipmentstate
140
     * @param OrderChangeShipmentStateAction|callable $action
141
     * @return $this
142
     */
143 1
    public function changeShipmentState($action = null)
144
    {
145 1
        $this->addAction($this->resolveAction(OrderChangeShipmentStateAction::class, $action));
146 1
        return $this;
147
    }
148
149
    /**
150
     * @link https://docs.commercetools.com/http-api-projects-orders.html#import-state-for-customlineitems
151
     * @param OrderImportCustomLineItemStateAction|callable $action
152
     * @return $this
153
     */
154 1
    public function importCustomLineItemState($action = null)
155
    {
156 1
        $this->addAction($this->resolveAction(OrderImportCustomLineItemStateAction::class, $action));
157 1
        return $this;
158
    }
159
160
    /**
161
     * @link https://docs.commercetools.com/http-api-projects-orders.html#import-state-for-lineitems
162
     * @param OrderImportLineItemStateAction|callable $action
163
     * @return $this
164
     */
165 1
    public function importLineItemState($action = null)
166
    {
167 1
        $this->addAction($this->resolveAction(OrderImportLineItemStateAction::class, $action));
168 1
        return $this;
169
    }
170
171
    /**
172
     * @link https://docs.commercetools.com/http-api-projects-orders.html#remove-delivery
173
     * @param OrderRemoveDeliveryAction|callable $action
174
     * @return $this
175
     */
176 1
    public function removeDelivery($action = null)
177
    {
178 1
        $this->addAction($this->resolveAction(OrderRemoveDeliveryAction::class, $action));
179 1
        return $this;
180
    }
181
182
    /**
183
     * @link https://docs.commercetools.com/http-api-projects-orders.html#remove-itemshippingaddress
184
     * @param OrderRemoveItemShippingAddressAction|callable $action
185
     * @return $this
186
     */
187 1
    public function removeItemShippingAddress($action = null)
188
    {
189 1
        $this->addAction($this->resolveAction(OrderRemoveItemShippingAddressAction::class, $action));
190 1
        return $this;
191
    }
192
193
    /**
194
     * @link https://docs.commercetools.com/http-api-projects-orders.html#remove-parcel-from-delivery
195
     * @param OrderRemoveParcelFromDeliveryAction|callable $action
196
     * @return $this
197
     */
198 1
    public function removeParcelFromDelivery($action = null)
199
    {
200 1
        $this->addAction($this->resolveAction(OrderRemoveParcelFromDeliveryAction::class, $action));
201 1
        return $this;
202
    }
203
204
    /**
205
     * @link https://docs.commercetools.com/http-api-projects-orders.html#remove-payment
206
     * @param OrderRemovePaymentAction|callable $action
207
     * @return $this
208
     */
209 1
    public function removePayment($action = null)
210
    {
211 1
        $this->addAction($this->resolveAction(OrderRemovePaymentAction::class, $action));
212 1
        return $this;
213
    }
214
215
    /**
216
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-billing-address
217
     * @param OrderSetBillingAddress|callable $action
218
     * @return $this
219
     */
220 1
    public function setBillingAddress($action = null)
221
    {
222 1
        $this->addAction($this->resolveAction(OrderSetBillingAddress::class, $action));
223 1
        return $this;
224
    }
225
226
    /**
227
     *
228
     * @param OrderSetBillingAddressCustomFieldAction|callable $action
229
     * @return $this
230
     */
231 1
    public function setBillingAddressCustomField($action = null)
232
    {
233 1
        $this->addAction($this->resolveAction(OrderSetBillingAddressCustomFieldAction::class, $action));
234 1
        return $this;
235
    }
236
237
    /**
238
     *
239
     * @param OrderSetBillingAddressCustomTypeAction|callable $action
240
     * @return $this
241
     */
242 1
    public function setBillingAddressCustomType($action = null)
243
    {
244 1
        $this->addAction($this->resolveAction(OrderSetBillingAddressCustomTypeAction::class, $action));
245 1
        return $this;
246
    }
247
248
    /**
249
     *
250
     * @param OrderSetCustomFieldAction|callable $action
251
     * @return $this
252
     */
253 1
    public function setCustomField($action = null)
254
    {
255 1
        $this->addAction($this->resolveAction(OrderSetCustomFieldAction::class, $action));
256 1
        return $this;
257
    }
258
259
    /**
260
     *
261
     * @param OrderSetCustomLineItemCustomFieldAction|callable $action
262
     * @return $this
263
     */
264 1
    public function setCustomLineItemCustomField($action = null)
265
    {
266 1
        $this->addAction($this->resolveAction(OrderSetCustomLineItemCustomFieldAction::class, $action));
267 1
        return $this;
268
    }
269
270
    /**
271
     *
272
     * @param OrderSetCustomLineItemCustomTypeAction|callable $action
273
     * @return $this
274
     */
275 1
    public function setCustomLineItemCustomType($action = null)
276
    {
277 1
        $this->addAction($this->resolveAction(OrderSetCustomLineItemCustomTypeAction::class, $action));
278 1
        return $this;
279
    }
280
281
    /**
282
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-customlineitemshippingdetails
283
     * @param OrderSetCustomLineItemShippingDetailsAction|callable $action
284
     * @return $this
285
     */
286 1
    public function setCustomLineItemShippingDetails($action = null)
287
    {
288 1
        $this->addAction($this->resolveAction(OrderSetCustomLineItemShippingDetailsAction::class, $action));
289 1
        return $this;
290
    }
291
292
    /**
293
     *
294
     * @param OrderSetCustomTypeAction|callable $action
295
     * @return $this
296
     */
297 1
    public function setCustomType($action = null)
298
    {
299 1
        $this->addAction($this->resolveAction(OrderSetCustomTypeAction::class, $action));
300 1
        return $this;
301
    }
302
303
    /**
304
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-customer-email
305
     * @param OrderSetCustomerEmail|callable $action
306
     * @return $this
307
     */
308 1
    public function setCustomerEmail($action = null)
309
    {
310 1
        $this->addAction($this->resolveAction(OrderSetCustomerEmail::class, $action));
311 1
        return $this;
312
    }
313
314
    /**
315
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-customer-id
316
     * @param OrderSetCustomerIdAction|callable $action
317
     * @return $this
318
     */
319 1
    public function setCustomerId($action = null)
320
    {
321 1
        $this->addAction($this->resolveAction(OrderSetCustomerIdAction::class, $action));
322 1
        return $this;
323
    }
324
325
    /**
326
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-delivery-address
327
     * @param OrderSetDeliveryAddressAction|callable $action
328
     * @return $this
329
     */
330 1
    public function setDeliveryAddress($action = null)
331
    {
332 1
        $this->addAction($this->resolveAction(OrderSetDeliveryAddressAction::class, $action));
333 1
        return $this;
334
    }
335
336
    /**
337
     *
338
     * @param OrderSetDeliveryAddressCustomFieldAction|callable $action
339
     * @return $this
340
     */
341 1
    public function setDeliveryAddressCustomField($action = null)
342
    {
343 1
        $this->addAction($this->resolveAction(OrderSetDeliveryAddressCustomFieldAction::class, $action));
344 1
        return $this;
345
    }
346
347
    /**
348
     *
349
     * @param OrderSetDeliveryAddressCustomTypeAction|callable $action
350
     * @return $this
351
     */
352 1
    public function setDeliveryAddressCustomType($action = null)
353
    {
354 1
        $this->addAction($this->resolveAction(OrderSetDeliveryAddressCustomTypeAction::class, $action));
355 1
        return $this;
356
    }
357
358
    /**
359
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-delivery-items
360
     * @param OrderSetDeliveryItemsAction|callable $action
361
     * @return $this
362
     */
363 1
    public function setDeliveryItems($action = null)
364
    {
365 1
        $this->addAction($this->resolveAction(OrderSetDeliveryItemsAction::class, $action));
366 1
        return $this;
367
    }
368
369
    /**
370
     *
371
     * @param OrderSetItemShippingAddressCustomFieldAction|callable $action
372
     * @return $this
373
     */
374 1
    public function setItemShippingAddressCustomField($action = null)
375
    {
376 1
        $this->addAction($this->resolveAction(OrderSetItemShippingAddressCustomFieldAction::class, $action));
377 1
        return $this;
378
    }
379
380
    /**
381
     *
382
     * @param OrderSetItemShippingAddressCustomTypeAction|callable $action
383
     * @return $this
384
     */
385 1
    public function setItemShippingAddressCustomType($action = null)
386
    {
387 1
        $this->addAction($this->resolveAction(OrderSetItemShippingAddressCustomTypeAction::class, $action));
388 1
        return $this;
389
    }
390
391
    /**
392
     *
393
     * @param OrderSetLineItemCustomFieldAction|callable $action
394
     * @return $this
395
     */
396 1
    public function setLineItemCustomField($action = null)
397
    {
398 1
        $this->addAction($this->resolveAction(OrderSetLineItemCustomFieldAction::class, $action));
399 1
        return $this;
400
    }
401
402
    /**
403
     *
404
     * @param OrderSetLineItemCustomTypeAction|callable $action
405
     * @return $this
406
     */
407 1
    public function setLineItemCustomType($action = null)
408
    {
409 1
        $this->addAction($this->resolveAction(OrderSetLineItemCustomTypeAction::class, $action));
410 1
        return $this;
411
    }
412
413
    /**
414
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-lineitemshippingdetails
415
     * @param OrderSetLineItemShippingDetailsAction|callable $action
416
     * @return $this
417
     */
418 1
    public function setLineItemShippingDetails($action = null)
419
    {
420 1
        $this->addAction($this->resolveAction(OrderSetLineItemShippingDetailsAction::class, $action));
421 1
        return $this;
422
    }
423
424
    /**
425
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-locale
426
     * @param OrderSetLocaleAction|callable $action
427
     * @return $this
428
     */
429 1
    public function setLocale($action = null)
430
    {
431 1
        $this->addAction($this->resolveAction(OrderSetLocaleAction::class, $action));
432 1
        return $this;
433
    }
434
435
    /**
436
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-order-number
437
     * @param OrderSetOrderNumberAction|callable $action
438
     * @return $this
439
     */
440 1
    public function setOrderNumber($action = null)
441
    {
442 1
        $this->addAction($this->resolveAction(OrderSetOrderNumberAction::class, $action));
443 1
        return $this;
444
    }
445
446
    /**
447
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-parcel-items
448
     * @param OrderSetParcelItemsAction|callable $action
449
     * @return $this
450
     */
451 1
    public function setParcelItems($action = null)
452
    {
453 1
        $this->addAction($this->resolveAction(OrderSetParcelItemsAction::class, $action));
454 1
        return $this;
455
    }
456
457
    /**
458
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-parcel-measurements
459
     * @param OrderSetParcelMeasurementsAction|callable $action
460
     * @return $this
461
     */
462 1
    public function setParcelMeasurements($action = null)
463
    {
464 1
        $this->addAction($this->resolveAction(OrderSetParcelMeasurementsAction::class, $action));
465 1
        return $this;
466
    }
467
468
    /**
469
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-parcel-tracking-data
470
     * @param OrderSetParcelTrackingDataAction|callable $action
471
     * @return $this
472
     */
473 1
    public function setParcelTrackingData($action = null)
474
    {
475 1
        $this->addAction($this->resolveAction(OrderSetParcelTrackingDataAction::class, $action));
476 1
        return $this;
477
    }
478
479
    /**
480
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-returnpaymentstate
481
     * @param OrderSetReturnPaymentStateAction|callable $action
482
     * @return $this
483
     */
484 1
    public function setReturnPaymentState($action = null)
485
    {
486 1
        $this->addAction($this->resolveAction(OrderSetReturnPaymentStateAction::class, $action));
487 1
        return $this;
488
    }
489
490
    /**
491
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-returnshipmentstate
492
     * @param OrderSetReturnShipmentStateAction|callable $action
493
     * @return $this
494
     */
495 1
    public function setReturnShipmentState($action = null)
496
    {
497 1
        $this->addAction($this->resolveAction(OrderSetReturnShipmentStateAction::class, $action));
498 1
        return $this;
499
    }
500
501
    /**
502
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-shipping-address
503
     * @param OrderSetShippingAddress|callable $action
504
     * @return $this
505
     */
506 1
    public function setShippingAddress($action = null)
507
    {
508 1
        $this->addAction($this->resolveAction(OrderSetShippingAddress::class, $action));
509 1
        return $this;
510
    }
511
512
    /**
513
     *
514
     * @param OrderSetShippingAddressCustomFieldAction|callable $action
515
     * @return $this
516
     */
517 1
    public function setShippingAddressCustomField($action = null)
518
    {
519 1
        $this->addAction($this->resolveAction(OrderSetShippingAddressCustomFieldAction::class, $action));
520 1
        return $this;
521
    }
522
523
    /**
524
     *
525
     * @param OrderSetShippingAddressCustomTypeAction|callable $action
526
     * @return $this
527
     */
528 1
    public function setShippingAddressCustomType($action = null)
529
    {
530 1
        $this->addAction($this->resolveAction(OrderSetShippingAddressCustomTypeAction::class, $action));
531 1
        return $this;
532
    }
533
534
    /**
535
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-store-beta
536
     * @param OrderSetStoreAction|callable $action
537
     * @return $this
538
     */
539 1
    public function setStore($action = null)
540
    {
541 1
        $this->addAction($this->resolveAction(OrderSetStoreAction::class, $action));
542 1
        return $this;
543
    }
544
545
    /**
546
     * @link https://docs.commercetools.com/http-api-projects-orders.html#change-the-state-of-customlineitem-according-to-allowed-transitions
547
     * @param OrderTransitionCustomLineItemStateAction|callable $action
548
     * @return $this
549
     */
550 1
    public function transitionCustomLineItemState($action = null)
551
    {
552 1
        $this->addAction($this->resolveAction(OrderTransitionCustomLineItemStateAction::class, $action));
553 1
        return $this;
554
    }
555
556
    /**
557
     * @link https://docs.commercetools.com/http-api-projects-orders.html#change-the-state-of-lineitem-according-to-allowed-transitions
558
     * @param OrderTransitionLineItemStateAction|callable $action
559
     * @return $this
560
     */
561 1
    public function transitionLineItemState($action = null)
562
    {
563 1
        $this->addAction($this->resolveAction(OrderTransitionLineItemStateAction::class, $action));
564 1
        return $this;
565
    }
566
567
    /**
568
     * @link https://docs.commercetools.com/http-api-projects-orders.html#transition-state
569
     * @param OrderTransitionStateAction|callable $action
570
     * @return $this
571
     */
572 1
    public function transitionState($action = null)
573
    {
574 1
        $this->addAction($this->resolveAction(OrderTransitionStateAction::class, $action));
575 1
        return $this;
576
    }
577
578
    /**
579
     * @link https://docs.commercetools.com/http-api-projects-orders.html#update-itemshippingaddress
580
     * @param OrderUpdateItemShippingAddressAction|callable $action
581
     * @return $this
582
     */
583 1
    public function updateItemShippingAddress($action = null)
584
    {
585 1
        $this->addAction($this->resolveAction(OrderUpdateItemShippingAddressAction::class, $action));
586 1
        return $this;
587
    }
588
589
    /**
590
     * @link https://docs.commercetools.com/http-api-projects-orders.html#update-syncinfo
591
     * @param OrderUpdateSyncInfoAction|callable $action
592
     * @return $this
593
     */
594 1
    public function updateSyncInfo($action = null)
595
    {
596 1
        $this->addAction($this->resolveAction(OrderUpdateSyncInfoAction::class, $action));
597 1
        return $this;
598
    }
599
600
    /**
601
     * @return OrdersActionBuilder
602
     */
603
    public static function of()
604
    {
605
        return new self();
606
    }
607
608
    /**
609
     * @param $class
610
     * @param $action
611
     * @return AbstractAction
612
     * @throws InvalidArgumentException
613
     */
614 49
    private function resolveAction($class, $action = null)
615
    {
616 49
        if (is_null($action) || is_callable($action)) {
617 49
            $callback = $action;
618 49
            $emptyAction = $class::of();
619 49
            $action = $this->callback($emptyAction, $callback);
620
        }
621 49
        if ($action instanceof $class) {
622 49
            return $action;
623
        }
624
        throw new InvalidArgumentException(
625
            sprintf('Expected method to be called with or callable to return %s', $class)
626
        );
627
    }
628
629
    /**
630
     * @param $action
631
     * @param callable $callback
632
     * @return AbstractAction
633
     */
634 49
    private function callback($action, callable $callback = null)
635
    {
636 49
        if (!is_null($callback)) {
637
            $action = $callback($action);
638
        }
639 49
        return $action;
640
    }
641
642
    /**
643
     * @param AbstractAction $action
644
     * @return $this;
645
     */
646 49
    public function addAction(AbstractAction $action)
647
    {
648 49
        $this->actions[] = $action;
649 49
        return $this;
650
    }
651
652
    /**
653
     * @return array
654
     */
655 49
    public function getActions()
656
    {
657 49
        return $this->actions;
658
    }
659
660
661
    /**
662
     * @param array $actions
663
     * @return $this
664
     */
665
    public function setActions(array $actions)
666
    {
667
        $this->actions = $actions;
668
        return $this;
669
    }
670
}
671