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

OrderSetParcelTrackingDataAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fieldDefinitions() 0 6 1
A ofParcel() 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\TrackingData;
10
use Commercetools\Core\Request\AbstractAction;
11
12
/**
13
 * @package Commercetools\Core\Request\Orders\Command
14
 *
15
 * @method string getAction()
16
 * @method OrderSetParcelTrackingDataAction setAction(string $action = null)
17
 * @method string getParcelId()
18
 * @method OrderSetParcelTrackingDataAction setParcelId(string $parcelId = null)
19
 * @method TrackingData getTrackingData()
20
 * @method OrderSetParcelTrackingDataAction setTrackingData(TrackingData $trackingData = null)
21
 */
22
class OrderSetParcelTrackingDataAction extends AbstractAction
23
{
24 2
    public function fieldDefinitions()
25
    {
26
        return [
27 2
            'action' => [static::TYPE => 'string'],
28 2
            'parcelId' => [static::TYPE => 'string'],
29 2
            'trackingData' => [static::TYPE => TrackingData::class]
30
        ];
31
    }
32
33
    /**
34
     * @param string $parcelId
35
     * @param Context|callable $context
36
     * @return OrderSetParcelTrackingDataAction
37
     */
38 1
    public static function ofParcel($parcelId, $context = null)
39
    {
40 1
        return static::of($context)->setParcelId($parcelId);
41
    }
42
43
    /**
44
     * @param array $data
45
     * @param Context|callable $context
46
     */
47 2
    public function __construct(array $data = [], $context = null)
48
    {
49 2
        parent::__construct($data, $context);
50 2
        $this->setAction('setParcelTrackingData');
51 2
    }
52
}
53