Passed
Push — master ( 78880b...ac7e2f )
by Jens
20:00 queued 13s
created

ZoneRateDraft   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
dl 0
loc 22
ccs 3
cts 5
cp 0.6
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldDefinitions() 0 5 1
A ofZoneAndShippingRates() 0 6 1
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Model\ShippingMethod;
7
8
use Commercetools\Core\Model\Common\Context;
9
use Commercetools\Core\Model\Common\JsonObject;
10
use Commercetools\Core\Model\Zone\ZoneReference;
11
12
/**
13
 * @package Commercetools\Core\Model\ShippingMethod
14
 * @link https://dev.commercetools.com/http-api-projects-shippingMethods.html#zoneratedraft
15
 * @method ZoneReference getZone()
16
 * @method ZoneRateDraft setZone(ZoneReference $zone = null)
17
 * @method ShippingRateDraftCollection getShippingRates()
18
 * @method ZoneRateDraft setShippingRates(ShippingRateDraftCollection $shippingRates = null)
19
 */
20
class ZoneRateDraft extends JsonObject
21
{
22 2
    public function fieldDefinitions()
23
    {
24
        return [
25 2
            'zone' => [static::TYPE => ZoneReference::class],
26 2
            'shippingRates' => [static::TYPE => ShippingRateDraftCollection::class]
27
        ];
28
    }
29
30
    /**
31
     * @param ZoneReference $zone
32
     * @param ShippingRateDraftCollection $shippingRates
33
     * @param Context|callable $context
34
     * @return ZoneRateDraft
35
     */
36
    public static function ofZoneAndShippingRates(
37
        ZoneReference $zone,
38
        ShippingRateDraftCollection $shippingRates,
39
        $context = null
40
    ) {
41
        return static::of($context)->setZone($zone)->setShippingRates($shippingRates);
42
    }
43
}
44