Completed
Push — master ( a0d538...0ed0ec )
by Adam
07:36
created

ProductContext::getSubject()   A

Complexity

Conditions 1
Paths 1

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 4
Code Lines 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/*
3
 * WellCommerce Open-Source E-Commerce Platform
4
 * 
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 * 
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
13
namespace WellCommerce\Bundle\OrderBundle\Context;
14
15
use WellCommerce\Bundle\CatalogBundle\Entity\Product;
16
use WellCommerce\Bundle\OrderBundle\Calculator\ShippingSubjectInterface;
17
18
/**
19
 * Class ProductAdapter
20
 *
21
 * @author  Adam Piotrowski <[email protected]>
22
 */
23
final class ProductContext implements ShippingSubjectInterface
24
{
25
    /**
26
     * @var Product
27
     */
28
    protected $product;
29
    
30
    public function __construct(Product $product)
31
    {
32
        $this->product = $product;
33
    }
34
    
35
    public function getQuantity(): int
36
    {
37
        return 1;
38
    }
39
    
40
    public function getWeight(): float
41
    {
42
        return $this->product->getWeight();
43
    }
44
    
45
    public function getGrossPrice(): float
46
    {
47
        return $this->product->getSellPrice()->getFinalGrossAmount();
48
    }
49
    
50
    public function getNetPrice(): float
51
    {
52
        return $this->product->getSellPrice()->getFinalNetAmount();
53
    }
54
    
55
    public function getTaxAmount(): float
56
    {
57
        return $this->product->getSellPrice()->getFinalTaxAmount();
58
    }
59
    
60
    public function getCurrency(): string
61
    {
62
        return $this->product->getSellPrice()->getCurrency();
63
    }
64
    
65
    public function getCountry(): string
66
    {
67
        return '';
68
    }
69
    
70
    public function getShop()
71
    {
72
        return null;
73
    }
74
    
75
    public function getSubject()
76
    {
77
        return $this->product;
78
    }
79
}
80