Passed
Push — master ( 9ff768...b736eb )
by Laurens
02:33
created

Product::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 23

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 8.8571
c 0
b 0
f 0
cc 1
eloc 23
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 Money\Money;
9
use Ramsey\Uuid\Uuid;
10
use Ramsey\Uuid\UuidInterface;
11
12
final class Product
13
{
14
    private $productUuid; //" => "3b3565e0-2694-11e7-b983-c70f05a416cd"
15
    private $variantUuid; //" => "c2a45f90-269e-11e7-9657-51506d0a8492"
16
    private $name; //" => "Munten"
17
    private $variantName; //" => "20 munten"
18
    private $quantity; //" => "1"
19
    private $unitPrice; //" => 1000
20
    private $vatPercentage; //" => 0.0
21
    private $rowTaxableAmount; //" => 1000
22
    private $imageLookupKey; //" => ""
23
    private $autoGenerated; //" => false
24
    private $libraryProduct;
25
26 1
    public function __construct(
27
        ?UuidInterface $productUuid = null,
28
        ?UuidInterface $variantUuid = null,
29
        ?string $name = null,
30
        ?string $variantName = null,
31
        int $quantity,
32
        Money $unitPrice,
33
        float $vatPercentage,
34
        Money $rowTaxableAmount,
35
        ?Image $imageLookupKey = null,
36
        bool $autoGenerated,
37
        bool $libraryProduct
38
    ) {
39 1
        $this->productUuid = $productUuid;
40 1
        $this->variantUuid = $variantUuid;
41 1
        $this->name = $name;
42 1
        $this->variantName = $variantName;
43 1
        $this->quantity = $quantity;
44 1
        $this->unitPrice = $unitPrice;
45 1
        $this->vatPercentage = $vatPercentage;
46 1
        $this->rowTaxableAmount = $rowTaxableAmount;
47 1
        $this->imageLookupKey = $imageLookupKey;
48 1
        $this->autoGenerated = $autoGenerated;
49 1
        $this->libraryProduct = $libraryProduct;
50 1
    }
51
52 1
    public function getProductUuid()
53
    {
54 1
        return $this->productUuid;
55
    }
56
57 1
    public function getVariantUuid()
58
    {
59 1
        return $this->variantUuid;
60
    }
61
62 1
    public function getName()
63
    {
64 1
        return $this->name;
65
    }
66
67 1
    public function getVariantName()
68
    {
69 1
        return $this->variantName;
70
    }
71
72 1
    public function getQuantity(): int
73
    {
74 1
        return $this->quantity;
75
    }
76
77 1
    public function getUnitPrice(): Money
78
    {
79 1
        return $this->unitPrice;
80
    }
81
82 1
    public function getVatPercentage(): float
83
    {
84 1
        return $this->vatPercentage;
85
    }
86
87 1
    public function getRowTaxableAmount(): Money
88
    {
89 1
        return $this->rowTaxableAmount;
90
    }
91
92 1
    public function getImageLookupKey()
93
    {
94 1
        return $this->imageLookupKey;
95
    }
96
97 1
    public function isAutoGenerated(): bool
98
    {
99 1
        return $this->autoGenerated;
100
    }
101
102 1
    public function isLibraryProduct(): bool
103
    {
104 1
        return $this->libraryProduct;
105
    }
106
}
107