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

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