Passed
Branch master (9ff768)
by Laurens
02:02
created

Purchase::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 37
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 37
ccs 19
cts 19
cp 1
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 35
nc 1
nop 17
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 DateTime;
8
use Money\Money;
9
use Ramsey\Uuid\UuidInterface;
10
11
final class Purchase
12
{
13
    private $Uuid;
14
    private $Uuid1;
15
    private $timestamp;
16
    private $coordinates;
17
    private $country;
18
    private $user;
19
    private $organizationId;
20
    private $purchaseNumber;
21
    private $amount;
22
    private $vatAmount;
23
    private $products;
24
    private $payments;
25
    private $vatAmounts;
26
    private $receiptCopyAllowed;
27
    private $published;
28
    private $refund;
29
    private $refunded;
30
31 4
    public function __construct(
32
        string $Uuid,
33
        UuidInterface $Uuid1,
34
        DateTime $timestamp,
35
        ?Coordinates $coordinates = null,
36
        string $country,
37
        User $user,
38
        int $organizationId,
39
        int $purchaseNumber,
40
        Money $amount,
41
        Money $vatAmount,
42
        array $products,
43
        array $payments,
44
        array $vatAmounts,
45
        bool $receiptCopyAllowed,
46
        ?bool $published = null,
47
        bool $refund,
48
        bool $refunded
49
    ) {
50 4
        $this->Uuid = $Uuid;
51 4
        $this->Uuid1 = $Uuid1;
52 4
        $this->timestamp = $timestamp;
53 4
        $this->coordinates = $coordinates;
54 4
        $this->country = $country;
55 4
        $this->user = $user;
56 4
        $this->organizationId = $organizationId;
57 4
        $this->purchaseNumber = $purchaseNumber;
58 4
        $this->amount = $amount;
59 4
        $this->vatAmount = $vatAmount;
60 4
        $this->products = $products;
61 4
        $this->payments = $payments;
62 4
        $this->vatAmounts = $vatAmounts;
63 4
        $this->receiptCopyAllowed = $receiptCopyAllowed;
64 4
        $this->published = $published;
65 4
        $this->refund = $refund;
66 4
        $this->refunded = $refunded;
67 4
    }
68
69 2
    public function getUuid(): string
70
    {
71 2
        return $this->Uuid;
72
    }
73
74 1
    public function getUuid1(): UuidInterface
75
    {
76 1
        return $this->Uuid1;
77
    }
78
79 1
    public function getTimestamp(): DateTime
80
    {
81 1
        return $this->timestamp;
82
    }
83
84 1
    public function getCoordinates(): ?Coordinates
85
    {
86 1
        return $this->coordinates;
87
    }
88
89 1
    public function getCountry(): string
90
    {
91 1
        return $this->country;
92
    }
93
94 1
    public function getUser(): User
95
    {
96 1
        return $this->user;
97
    }
98
99 1
    public function getOrganizationId(): int
100
    {
101 1
        return $this->organizationId;
102
    }
103
104 1
    public function getPurchaseNumber(): int
105
    {
106 1
        return $this->purchaseNumber;
107
    }
108
109 1
    public function getAmount(): Money
110
    {
111 1
        return $this->amount;
112
    }
113
114 1
    public function getVatAmount(): Money
115
    {
116 1
        return $this->vatAmount;
117
    }
118
119 1
    public function getProducts(): array
120
    {
121 1
        return $this->products;
122
    }
123
124 1
    public function getPayments(): array
125
    {
126 1
        return $this->payments;
127
    }
128
129 1
    public function getVatAmounts(): array
130
    {
131 1
        return $this->vatAmounts;
132
    }
133
134 1
    public function isReceiptCopyAllowed(): bool
135
    {
136 1
        return $this->receiptCopyAllowed;
137
    }
138
139 1
    public function getPublished()
140
    {
141 1
        return $this->published;
142
    }
143
144 1
    public function isRefund(): bool
145
    {
146 1
        return $this->refund;
147
    }
148
149 1
    public function isRefunded(): bool
150
    {
151 1
        return $this->refunded;
152
    }
153
}
154