Passed
Pull Request — master (#93)
by
unknown
13:46 queued 06:13
created

TaxUnitItemResolver::getTaxZone()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 3
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * You can find more information about us on https://bitbag.io and write us
7
 * an email on [email protected].
8
 */
9
10
declare(strict_types=1);
11
12
namespace BitBag\SyliusMolliePlugin\Resolver;
13
14
use Sylius\Component\Core\Model\OrderInterface;
15
use Sylius\Component\Core\Model\OrderItem;
16
use Sylius\Component\Taxation\Calculator\CalculatorInterface;
17
use Sylius\Component\Taxation\Resolver\TaxRateResolverInterface;
18
19
final class TaxUnitItemResolver implements TaxUnitItemResolverInterface
20
{
21
    /** @var TaxRateResolverInterface */
22
    private $taxRateResolver;
23
24
    /** @var CalculatorInterface */
25
    private $calculator;
26
27
    public function __construct(
28
        TaxRateResolverInterface $taxRateResolver,
29
        CalculatorInterface $calculator
30
    ) {
31
        $this->taxRateResolver = $taxRateResolver;
32
        $this->calculator = $calculator;
33
    }
34
35
    public function resolve(OrderInterface $order, OrderItem $item): float
36
    {
37
//        if ($item->getTaxTotal() === 0) {
38
//            return 0;
39
//        }
40
        $rate = $this->taxRateResolver->resolve($item->getVariant());
41
        dd($item->getTaxTotal());
42
43
        return $rate->getAmount();
44
    }
45
}
46