Completed
Push — master ( 4f3285...cedc69 )
by Ronaldo
02:00
created

ItemTotalValue   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A execute() 0 6 1
1
<?php
2
3
namespace WSW\SiftScience\Services;
4
5
use WSW\Money\Money;
6
use WSW\SiftScience\Entities\Item;
7
8
/**
9
 * Class ItemTotalValue
10
 *
11
 * @package WSW\SiftScience\Services
12
 * @author Ronaldo Matos Rodrigues <[email protected]>
13
 */
14
class ItemTotalValue implements ServiceContract
15
{
16
    /**
17
     * @var Item
18
     */
19
    private $item;
20
21
    /**
22
     * @param Item $item
23
     */
24 1
    public function __construct(Item $item)
25
    {
26 1
        $this->item = $item;
27 1
    }
28
29
    /**
30
     * @return Money
31
     */
32 1
    public function execute()
33
    {
34 1
        $newAmount = bcmul($this->item->getPrice()->getAmount(), $this->item->getQuantity(), Money::SCALE);
35
36 1
        return $this->item->getPrice()->newInstance($newAmount);
37
    }
38
}
39