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

OrderSetDeliveryItemsAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 30
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldDefinitions() 0 6 1
A __construct() 0 4 1
A ofDeliveryAndItems() 0 3 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