Completed
Push — master ( 9c37c7...1d2d63 )
by Jens
08:02
created

DiscountedPricePerQuantity   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 21
ccs 0
cts 14
cp 0
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#discounted-line-item-price-for-quantity
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
    public function fieldDefinitions()
22
    {
23
        return [
24
            'quantity' => [static::TYPE => 'int'],
25
            'discountedPrice' => [static::TYPE => '\Commercetools\Core\Model\Cart\DiscountedLineItemPrice']
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