Passed
Push — develop ( b811fe...1e6961 )
by Jens
07:26 queued 12s
created

CartDiscountSetKeyAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

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