TaxUnitItemResolver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 5 2
A __construct() 0 6 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
        $rate = $this->taxRateResolver->resolve($item->getVariant());
38
39
        return null === $rate ? null : $rate->getAmount();
40
    }
41
}
42