Payment::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 8
dl 0
loc 19
ccs 10
cts 10
cp 1
crap 1
rs 9.6333
c 0
b 0
f 0

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
namespace PHPSC\PagSeguro\Purchases\Transactions;
3
4
use DateTime;
5
6
class Payment
7
{
8
    /**
9
     * @var DateTime
10
     */
11
    private $escrowEndDate;
12
13
    /**
14
     * @var PaymentMethod
15
     */
16
    private $paymentMethod;
17
18
    /**
19
     * @var float
20
     */
21
    private $grossAmount;
22
23
    /**
24
     * @var float
25
     */
26
    private $discountAmount;
27
28
    /**
29
     * @var float
30
     */
31
    private $feeAmount;
32
33
    /**
34
     * @var float
35
     */
36
    private $netAmount;
37
38
    /**
39
     * @var float
40
     */
41
    private $extraAmount;
42
43
    /**
44
     * @var int
45
     */
46
    private $installmentCount;
47
48
    /**
49
     * @param PaymentMethod $paymentMethod
50
     * @param float $grossAmount
51
     * @param float $discountAmount
52
     * @param float $feeAmount
53
     * @param float $netAmount
54
     * @param float $extraAmount
55
     * @param int $installmentCount
56
     * @param DateTime $escrowEndDate
57
     */
58 10
    public function __construct(
59
        PaymentMethod $paymentMethod,
60
        $grossAmount,
61
        $discountAmount,
62
        $feeAmount,
63
        $netAmount,
64
        $extraAmount,
65
        $installmentCount,
66
        DateTime $escrowEndDate = null
67
    ) {
68 10
        $this->escrowEndDate = $escrowEndDate;
69 10
        $this->paymentMethod = $paymentMethod;
70 10
        $this->grossAmount = $grossAmount;
71 10
        $this->discountAmount = $discountAmount;
72 10
        $this->feeAmount = $feeAmount;
73 10
        $this->netAmount = $netAmount;
74 10
        $this->extraAmount = $extraAmount;
75 10
        $this->installmentCount = $installmentCount;
76 10
    }
77
78
    /**
79
     * @return DateTime
80
     */
81 1
    public function getEscrowEndDate()
82
    {
83 1
        return $this->escrowEndDate;
84
    }
85
86
    /**
87
     * @return PaymentMethod
88
     */
89 1
    public function getPaymentMethod()
90
    {
91 1
        return $this->paymentMethod;
92
    }
93
94
    /**
95
     * @return number
96
     */
97 1
    public function getGrossAmount()
98
    {
99 1
        return $this->grossAmount;
100
    }
101
102
    /**
103
     * @return number
104
     */
105 1
    public function getDiscountAmount()
106
    {
107 1
        return $this->discountAmount;
108
    }
109
110
    /**
111
     * @return number
112
     */
113 1
    public function getFeeAmount()
114
    {
115 1
        return $this->feeAmount;
116
    }
117
118
    /**
119
     * @return number
120
     */
121 1
    public function getNetAmount()
122
    {
123 1
        return $this->netAmount;
124
    }
125
126
    /**
127
     * @return number
128
     */
129 1
    public function getExtraAmount()
130
    {
131 1
        return $this->extraAmount;
132
    }
133
134
    /**
135
     * @return number
136
     */
137 1
    public function getInstallmentCount()
138
    {
139 1
        return $this->installmentCount;
140
    }
141
}
142