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

fieldDefinitions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 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