Passed
Push — develop ( 02676e...d2b63d )
by Jens
08:11
created

DiscountedPricePerQuantity   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 42.86%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 21
ccs 3
cts 7
cp 0.4286
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldDefinitions() 0 7 1
A getDiscountedTotal() 0 7 1
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Model\Cart;
7
8
use Commercetools\Core\Model\Common\JsonObject;
9
use Commercetools\Core\Model\Common\Money;
10
11
/**
12
 * @package Commercetools\Core\Model\Cart
13
 * @link https://dev.commercetools.com/http-api-projects-carts.html#discountedlineitempriceforquantity
14
 * @method int getQuantity()
15
 * @method DiscountedPricePerQuantity setQuantity(int $quantity = null)
16
 * @method DiscountedLineItemPrice getDiscountedPrice()
17
 * @method DiscountedPricePerQuantity setDiscountedPrice(DiscountedLineItemPrice $discountedPrice = null)
18
 */
19
class DiscountedPricePerQuantity extends JsonObject
20
{
21 2
    public function fieldDefinitions()
22
    {
23
        return [
24 2
            'quantity' => [static::TYPE => 'int'],
25 2
            'discountedPrice' => [static::TYPE => DiscountedLineItemPrice::class]
26
        ];
27
    }
28
29
    /**
30
     * @return Money
31
     */
32
    public function getDiscountedTotal()
33
    {
34
        return Money::ofCurrencyAndAmount(
35
            $this->getDiscountedPrice()->getValue()->getCurrencyCode(),
36
            $this->getDiscountedPrice()->getValue()->getCentAmount() * $this->getQuantity()
37
        );
38
    }
39
}
40