Passed
Push — develop ( 1795ba...79eaf3 )
by Jens
25:35 queued 03:06
created

ShippingRateDraft   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 19
ccs 4
cts 6
cp 0.6667
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldDefinitions() 0 6 1
A ofPrice() 0 3 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\Common\Money;
11
12
/**
13
 * @package Commercetools\Core\Model\ShippingMethod
14
 * @link https://dev.commercetools.com/http-api-projects-shippingMethods.html#shippingratedraft
15
 * @method Money getPrice()
16
 * @method ShippingRateDraft setPrice(Money $price = null)
17
 * @method Money getFreeAbove()
18
 * @method ShippingRateDraft setFreeAbove(Money $freeAbove = null)
19
 * @method ShippingRatePriceTierCollection getTiers()
20
 * @method ShippingRateDraft setTiers(ShippingRatePriceTierCollection $tiers = null)
21
 */
22
class ShippingRateDraft extends JsonObject
23
{
24 139
    public function fieldDefinitions()
25
    {
26
        return [
27 139
            'price' => [static::TYPE => Money::class],
28 139
            'freeAbove' => [static::TYPE => Money::class],
29 139
            'tiers' => [static::TYPE => ShippingRatePriceTierCollection::class]
30
        ];
31
    }
32
33
    /**
34
     * @param Money $price
35
     * @param Context|callable $context
36
     * @return ShippingRateDraft
37
     */
38
    public static function ofPrice(Money $price, $context = null)
39
    {
40
        return static::of($context)->setPrice($price);
41
    }
42
}
43