Passed
Branch develop (523929)
by Jens
09:57
created

DiscountCodeSetValidFromAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 23
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldDefinitions() 0 10 1
A __construct() 0 5 1
1
<?php
2
/**
3
 * @author @jenschude <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Request\DiscountCodes\Command;
7
8
use Commercetools\Core\Model\Common\Context;
9
use Commercetools\Core\Model\Common\DateTimeDecorator;
10
use Commercetools\Core\Request\AbstractAction;
11
use DateTime;
12
13
/**
14
 * @package Commercetools\Core\Request\DiscountCodes\Command
15
 * @link https://docs.commercetools.com/http-api-projects-discountCodes.html#set-valid-from
16
 * @method string getAction()
17
 * @method DiscountCodeSetValidFromAction setAction(string $action = null)
18
 * @method DiscountCodeSetValidFromAction setValidFrom(DateTime $validFrom = null)
19
 * @method DateTimeDecorator getValidFrom()
20
 */
21
class DiscountCodeSetValidFromAction extends AbstractAction
22
{
23 1
    public function fieldDefinitions()
24
    {
25
        return [
26 1
            'action' => [static::TYPE => 'string'],
27
            'validFrom' => [
28 1
                static::TYPE => DateTime::class,
29 1
                static::DECORATOR => DateTimeDecorator::class
30
            ],
31
        ];
32
    }
33
34
    /**
35
     * @param array $data
36
     * @param Context|callable $context
37
     */
38 1
    public function __construct(array $data = [], $context = null)
39
    {
40 1
        parent::__construct($data, $context);
41 1
        $this->setAction('setValidFrom');
42 1
    }
43
}
44