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

ShippingRateDraft::ofPrice()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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