Test Failed
Push — master ( 07c34e...38ffd6 )
by Barbara
68:04 queued 25:46
created

CartSetItemShippingAddressCustomFieldAction   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldDefinitions() 0 7 1
A ofAddressKey() 0 3 1
A ofNameAndAddressKey() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
namespace Commercetools\Core\Request\Carts\Command;
4
5
use Commercetools\Core\Model\Common\Context;
6
use Commercetools\Core\Request\CustomField\Command\SetCustomFieldAction;
7
8
/**
9
 * @package Commercetools\Core\Request\Carts\Command
10
 *
11
 * @method string getAction()
12
 * @method CartSetItemShippingAddressCustomFieldAction setAction(string $action = null)
13
 * @method string getName()
14
 * @method CartSetItemShippingAddressCustomFieldAction setName(string $name = null)
15
 * @method mixed getValue()
16
 * @method CartSetItemShippingAddressCustomFieldAction setValue($value = null)
17
 * @method string getAddressKey()
18
 * @method CartSetItemShippingAddressCustomFieldAction setAddressKey(string $addressKey = null)
19
 */
20
class CartSetItemShippingAddressCustomFieldAction extends SetCustomFieldAction
21
{
22
    public function fieldDefinitions()
23
    {
24
        return [
25
            'action' => [static::TYPE => 'string'],
26
            'addressKey' => [static::TYPE => 'string'],
27
            'name' => [static::TYPE => 'string'],
28
            'value' => [static::TYPE => null],
29
        ];
30
    }
31
32
    /**
33
     * @param array $data
34
     * @param Context|callable $context
35
     */
36
    public function __construct(array $data = [], $context = null)
37
    {
38
        parent::__construct($data, $context);
39
        $this->setAction('setItemShippingAddressCustomField');
40
    }
41
42
    public static function ofNameAndAddressKey($name, $addressKey, $context = null)
43
    {
44
        return static::of($context)->setName($name)->setAddressKey($addressKey);
45
    }
46
47
    public static function ofAddressKey($addressKey, $context = null)
48
    {
49
        return static::of($context)->setAddressKey($addressKey);
50
    }
51
}
52