Completed
Push — master ( 18bfc7...82e0b5 )
by Jens
18:00 queued 05:19
created

DiscountedPrice   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 23
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldDefinitions() 0 7 1
A ofMoneyAndDiscount() 0 5 1
1
<?php
2
/**
3
 * @author @jayS-de <[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://dev.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 4
    public function fieldDefinitions()
22
    {
23
        return [
24 4
            'value' => [self::TYPE => '\Commercetools\Core\Model\Common\Money'],
25 4
            'discount' => [self::TYPE => '\Commercetools\Core\Model\ProductDiscount\ProductDiscountReference'],
26
        ];
27
    }
28
29
30
    /**
31
     * @param Money $value
32
     * @param ProductDiscountReference $discount
33
     * @param Context|callable $context
34
     * @return DiscountedPrice
35
     */
36 2
    public static function ofMoneyAndDiscount(Money $value, ProductDiscountReference $discount, $context = null)
37
    {
38 2
        $price = static::of($context);
39 2
        return $price->setValue($value)->setDiscount($discount);
40
    }
41
}
42