TaxRule   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 94
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 23 1
A getDocumentId() 0 4 1
A toElasticArray() 0 14 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\Document;
14
15
use BitBag\SyliusVueStorefrontPlugin\Document\TaxRule\Rates;
16
17
class TaxRule implements Indexable
18
{
19
    private const ENTITY_ID = 'id';
20
21
    private const CODE = 'code';
22
23
    private const PRIORITY = 'priority';
24
25
    private const POSITION = 'position';
26
27
    private const CUSTOMER_TAX_CLASS_IDS = 'customer_tax_class_ids';
28
29
    private const PRODUCT_TAX_CLASS_IDS = 'product_tax_class_ids';
30
31
    private const TAX_RATE_IDS = 'tax_rate_ids';
32
33
    private const CALCULATE_SUBTOTAL = 'calculate_subtotal';
34
35
    private const TAX_RATES = 'rates';
36
37
    /** @var int */
38
    private $documentId;
39
40
    /** @var int */
41
    private $entityId;
42
43
    /** @var string */
44
    private $code;
45
46
    /** @var int */
47
    private $priority;
48
49
    /** @var int */
50
    private $position;
51
52
    /** @var int[] */
53
    private $customerTaxClassIds;
54
55
    /** @var int[] */
56
    private $productTaxClassIds;
57
58
    /** @var int[] */
59
    private $taxRateIds;
60
61
    /** @var bool */
62
    private $calculateSubtotal;
63
64
    /** @var Rates */
65
    private $taxRates;
66
67
    public function __construct(
68
        int $documentId,
69
        int $entityId,
70
        string $code,
71
        int $priority,
72
        int $position,
73
        array $customerTaxClassIds,
74
        array $productTaxClassIds,
75
        array $taxRateIds,
76
        bool $calculateSubtotal,
77
        Rates $taxRates
78
    ) {
79
        $this->documentId = $documentId;
80
        $this->entityId = $entityId;
81
        $this->code = $code;
82
        $this->priority = $priority;
83
        $this->position = $position;
84
        $this->customerTaxClassIds = $customerTaxClassIds;
85
        $this->productTaxClassIds = $productTaxClassIds;
86
        $this->taxRateIds = $taxRateIds;
87
        $this->calculateSubtotal = $calculateSubtotal;
88
        $this->taxRates = $taxRates;
89
    }
90
91
    public function getDocumentId(): int
92
    {
93
        return $this->documentId;
94
    }
95
96
    public function toElasticArray(): array
97
    {
98
        return [
99
            self::ENTITY_ID => $this->entityId,
100
            self::CODE => $this->code,
101
            self::PRIORITY => $this->priority,
102
            self::POSITION => $this->position,
103
            self::CUSTOMER_TAX_CLASS_IDS => $this->customerTaxClassIds,
104
            self::PRODUCT_TAX_CLASS_IDS => $this->productTaxClassIds,
105
            self::TAX_RATE_IDS => $this->taxRateIds,
106
            self::CALCULATE_SUBTOTAL => $this->calculateSubtotal,
107
            self::TAX_RATES => $this->taxRates,
108
        ];
109
    }
110
}
111