Test Failed
Pull Request — develop (#694)
by Barbara
23:05
created

CartSetLineItemSupplyChannelAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
dl 0
loc 30
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldDefinitions() 0 6 1
A ofItemLineIdAndSupplyChannel() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
namespace Commercetools\Core\Request\Carts\Command;
4
5
use Commercetools\Core\Model\Channel\ChannelReference;
6
use Commercetools\Core\Model\Common\Context;
7
use Commercetools\Core\Model\Common\ResourceIdentifier;
8
use Commercetools\Core\Request\AbstractAction;
9
10
/**
11
 * @package Commercetools\Core\Request\Carts\Command
12
 *
13
 * @method string getAction()
14
 * @method CartSetLineItemSupplyChannelAction setAction(string $action = null)
15
 * @method string getLineItemId()
16
 * @method CartSetLineItemSupplyChannelAction setLineItemId(string $lineItemId = null)
17
 * @method ChannelReference getSupplyChannel()
18
 * @method CartSetLineItemSupplyChannelAction setSupplyChannel(ChannelReference $supplyChannel = null)
19
 */
20
class CartSetLineItemSupplyChannelAction extends AbstractAction
21
{
22
    public function fieldDefinitions()
23
    {
24
        return [
25
            'action' => [static::TYPE => 'string'],
26
            'lineItemId' => [static::TYPE => 'string'],
27
            'supplyChannel' => [static::TYPE => ChannelReference::class],
28
        ];
29
    }
30
31
    /**
32
     * @param array $data
33
     * @param Context|callable $context
34
     */
35
    public function __construct(array $data = [], $context = null)
36
    {
37
        parent::__construct($data, $context);
38
        $this->setAction('setLineItemSupplyChannel');
39
    }
40
41
    /**
42
     * @param String $itemLineId
43
     * @param ResourceIdentifier|ChannelReference $supplyChannel
44
     * @param Context|callable $context
45
     * @return CartSetLineItemSupplyChannelAction
46
     */
47
    public static function ofItemLineIdAndSupplyChannel($itemLineId, ChannelReference $supplyChannel, $context = null)
48
    {
49
        return static::of($context)->setLineItemId($itemLineId)->setSupplyChannel($supplyChannel);
50
    }
51
}
52