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

ItemTotalValue::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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