Passed
Branch develop (d03339)
by Jens
09:28
created

OrderSetDeliveryItemsAction::__construct()   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
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * @author @jenschude <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Request\Orders\Command;
7
8
use Commercetools\Core\Model\Common\Context;
9
use Commercetools\Core\Model\Order\DeliveryItemCollection;
10
use Commercetools\Core\Request\AbstractAction;
11
12
/**
13
 * @package Commercetools\Core\Request\Orders\Command
14
 *
15
 * @method string getAction()
16
 * @method OrderSetDeliveryItemsAction setAction(string $action = null)
17
 * @method string getDeliveryId()
18
 * @method OrderSetDeliveryItemsAction setDeliveryId(string $deliveryId = null)
19
 * @method DeliveryItemCollection getItems()
20
 * @method OrderSetDeliveryItemsAction setItems(DeliveryItemCollection $items = null)
21
 */
22
class OrderSetDeliveryItemsAction extends AbstractAction
23
{
24 2
    public function fieldDefinitions()
25
    {
26
        return [
27 2
            'action' => [static::TYPE => 'string'],
28 2
            'deliveryId' => [static::TYPE => 'string'],
29 2
            'items' => [static::TYPE => DeliveryItemCollection::class]
30
        ];
31
    }
32
33
    /**
34
     * @param string $deliveryId
35
     * @param DeliveryItemCollection $items
36
     * @param Context|callable $context
37
     * @return OrderSetDeliveryItemsAction
38
     */
39 1
    public static function ofDeliveryAndItems($deliveryId, DeliveryItemCollection $items, $context = null)
40
    {
41 1
        return static::of($context)->setDeliveryId($deliveryId)->setItems($items);
42
    }
43
44
    /**
45
     * @param array $data
46
     * @param Context|callable $context
47
     */
48 2
    public function __construct(array $data = [], $context = null)
49
    {
50 2
        parent::__construct($data, $context);
51 2
        $this->setAction('setDeliveryItems');
52 2
    }
53
}
54