BankAccount::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 8
dl 0
loc 19
rs 10

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
namespace Endeken\OFX;
4
5
use DateTime;
6
7
class BankAccount
8
{
9
    /**
10
     * @var string
11
     */
12
    public string $accountNumber;
13
14
    /**
15
     * @var string
16
     */
17
    public string $accountType;
18
19
    /**
20
     * @var string
21
     */
22
    public string $balance;
23
24
    /**
25
     * @var DateTime
26
     */
27
    public DateTime $balanceDate;
28
29
    /**
30
     * @var string
31
     */
32
    public string $routingNumber;
33
34
    /**
35
     * @var Statement
36
     */
37
    public Statement $statement;
38
39
    /**
40
     * @var string
41
     */
42
    public string $transactionUid;
43
44
    /**
45
     * @var string
46
     */
47
    public string $agencyNumber;
48
49
    public function __construct(
50
        string $accountNumber,
51
        string $accountType,
52
        string $agencyNumber,
53
        string $routingNumber,
54
        string $balance,
55
        DateTime $balanceDate,
56
        string $transactionUid,
57
        Statement $statement,
58
    )
59
    {
60
        $this->accountNumber = $accountNumber;
61
        $this->accountType = $accountType;
62
        $this->agencyNumber = $agencyNumber;
63
        $this->routingNumber = $routingNumber;
64
        $this->balance = $balance;
65
        $this->balanceDate = $balanceDate;
66
        $this->transactionUid = $transactionUid;
67
        $this->statement = $statement;
68
    }
69
}