Test Failed
Push — develop ( c17639...818a9c )
by Jens
09:56
created

DiscountedPrice::ofMoneyAndDiscount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 2
1
<?php
2
/**
3
 * @author @jenschude <[email protected]>
4
 * @created: 04.02.15, 17:13
5
 */
6
7
namespace Commercetools\Core\Model\Common;
8
9
use Commercetools\Core\Model\ProductDiscount\ProductDiscountReference;
10
11
/**
12
 * @package Commercetools\Core\Model\Common
13
 * @link https://docs.commercetools.com/http-api-projects-products.html#discountedprice
14
 * @method Money getValue()
15
 * @method ProductDiscountReference getDiscount()
16
 * @method DiscountedPrice setValue(Money $value = null)
17
 * @method DiscountedPrice setDiscount(ProductDiscountReference $discount = null)
18
 */
19
class DiscountedPrice extends JsonObject
20
{
21 2
    public function fieldDefinitions()
22
    {
23
        return [
24 2
            'value' => [self::TYPE => Money::class],
25 2
            'discount' => [self::TYPE => ProductDiscountReference::class],
26
        ];
27
    }
28
29
30
    /**
31
     * @param Money $value
32
     * @param ProductDiscountReference $discount
33
     * @param Context|callable $context
34
     * @return DiscountedPrice
35
     */
36
    public static function ofMoneyAndDiscount(Money $value, ProductDiscountReference $discount, $context = null)
37
    {
38
        $price = static::of($context);
39
        return $price->setValue($value)->setDiscount($discount);
40
    }
41
}
42