SyliusTaxCategoryToTaxRuleTransformer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A transform() 0 18 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
 * another great project.
7
 * You can find more information about us on https://bitbag.io and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusVueStorefrontPlugin\Sylius\Transformer;
14
15
use BitBag\SyliusVueStorefrontPlugin\Document\TaxRule;
16
use BitBag\SyliusVueStorefrontPlugin\Sylius\Transformer\SyliusTaxCategory\TaxRatesTransformerInterface;
17
use Sylius\Component\Taxation\Model\TaxCategoryInterface;
18
19
final class SyliusTaxCategoryToTaxRuleTransformer implements SyliusTaxCategoryToTaxRuleTransformerInterface
20
{
21
    /** @var TaxRatesTransformerInterface */
22
    private $taxRatesTransformer;
23
24
    public function __construct(TaxRatesTransformerInterface $taxRatesTransformer)
25
    {
26
        $this->taxRatesTransformer = $taxRatesTransformer;
27
    }
28
29
    public function transform(TaxCategoryInterface $taxCategory): TaxRule
30
    {
31
        $rates = $this->taxRatesTransformer->transform($taxCategory->getRates());
32
33
        return new TaxRule(
34
            $taxCategory->getId(),
35
            $taxCategory->getId(),
36
            $taxCategory->getCode(),
37
            0,
38
            0,
39
            [],
40
            [],
41
            [],
42
            false,
43
            $rates/*,
44
            5*/
45
        );
46
    }
47
}
48