Passed
Branch releases/1.0-dev (6a4c8c)
by Laurens
03:03
created

Product::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 13
cts 13
cp 1
rs 9.52
c 0
b 0
f 0
cc 1
nc 1
nop 11
crap 1

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\IzettleApi\API\Purchase;
6
7
use LauLamanApps\IzettleApi\API\Image;
8
use LauLamanApps\IzettleApi\API\Universal\Vat;
9
use Money\Money;
10
use Ramsey\Uuid\Uuid;
11
use Ramsey\Uuid\UuidInterface;
12
13
final class Product
14
{
15
    /**
16
     * @var UuidInterface|null
17
     */
18
    private $productUuid;
19
20
    /**
21
     * @var UuidInterface|null
22
     */
23
    private $variantUuid;
24
25
    /**
26
     * @var string|null
27
     */
28
    private $name;
29
30
    /**
31
     * @var string|null
32
     */
33
    private $variantName;
34
35
    /**
36
     * @var int
37
     */
38
    private $quantity;
39
40
    /**
41
     * @var Money
42
     */
43
    private $unitPrice;
44
45
    /**
46
     * @var Vat|null
47
     */
48
    private $vat;
49
50
    /**
51
     * @var Money
52
     */
53
    private $rowTaxableAmount;
54
55
    /**
56
     * @var Image|null
57
     */
58
    private $imageLookupKey;
59
60
    /**
61
     * @var bool
62
     */
63
    private $autoGenerated;
64
65
    /**
66
     * @var bool
67
     */
68
    private $libraryProduct;
69
70
71 3
    public function __construct(
72
        ?UuidInterface $productUuid = null,
73
        ?UuidInterface $variantUuid = null,
74
        ?string $name = null,
75
        ?string $variantName = null,
76
        int $quantity,
77
        Money $unitPrice,
78
        ?Vat $vat = null,
79
        Money $rowTaxableAmount,
80
        ?Image $imageLookupKey = null,
81
        bool $autoGenerated,
82
        bool $libraryProduct
83
    ) {
84 3
        $this->productUuid = $productUuid;
85 3
        $this->variantUuid = $variantUuid;
86 3
        $this->name = $name;
87 3
        $this->variantName = $variantName;
88 3
        $this->quantity = $quantity;
89 3
        $this->unitPrice = $unitPrice;
90 3
        $this->vat = $vat;
91 3
        $this->rowTaxableAmount = $rowTaxableAmount;
92 3
        $this->imageLookupKey = $imageLookupKey;
93 3
        $this->autoGenerated = $autoGenerated;
94 3
        $this->libraryProduct = $libraryProduct;
95 3
    }
96
97 1
    public function getProductUuid()
98
    {
99 1
        return $this->productUuid;
100
    }
101
102 1
    public function getVariantUuid()
103
    {
104 1
        return $this->variantUuid;
105
    }
106
107 3
    public function getName()
108
    {
109 3
        return $this->name;
110
    }
111
112 3
    public function getVariantName()
113
    {
114 3
        return $this->variantName;
115
    }
116
117 3
    public function getQuantity(): int
118
    {
119 3
        return $this->quantity;
120
    }
121
122 3
    public function getUnitPrice(): Money
123
    {
124 3
        return $this->unitPrice;
125
    }
126
127 3
    public function getVat(): ?Vat
128
    {
129 3
        return $this->vat;
130
    }
131
132 3
    public function getRowTaxableAmount(): Money
133
    {
134 3
        return $this->rowTaxableAmount;
135
    }
136
137 1
    public function getImageLookupKey()
138
    {
139 1
        return $this->imageLookupKey;
140
    }
141
142 3
    public function isAutoGenerated(): bool
143
    {
144 3
        return $this->autoGenerated;
145
    }
146
147 3
    public function isLibraryProduct(): bool
148
    {
149 3
        return $this->libraryProduct;
150
    }
151
}
152