Payee::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
c 0
b 0
f 0
nc 1
nop 9
dl 0
loc 20
rs 9.9666

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 Beccha\OfxParser\Entity;
6
7
final class Payee
8
{
9
    private string $name;
10
    private string $address1;
11
    private string $address2;
12
    private string $address3;
13
    private string $city;
14
    private string $state;
15
    private string $postalCode;
16
    private string $country;
17
    private string $phone;
18
19
    public function __construct(
20
        string $name,
21
        string $address1,
22
        string $address2,
23
        string $address3,
24
        string $city,
25
        string $state,
26
        string $postalCode,
27
        string $country,
28
        string $phone
29
    ) {
30
        $this->name = $name;
31
        $this->address1 = $address1;
32
        $this->address2 = $address2;
33
        $this->address3 = $address3;
34
        $this->city = $city;
35
        $this->state = $state;
36
        $this->postalCode = $postalCode;
37
        $this->country = $country;
38
        $this->phone = $phone;
39
    }
40
41
    public function getName(): string
42
    {
43
        return $this->name;
44
    }
45
46
    public function getAddress1(): string
47
    {
48
        return $this->address1;
49
    }
50
51
    public function getAddress2(): string
52
    {
53
        return $this->address2;
54
    }
55
56
    public function getAddress3(): string
57
    {
58
        return $this->address3;
59
    }
60
61
    public function getCity(): string
62
    {
63
        return $this->city;
64
    }
65
66
    public function getState(): string
67
    {
68
        return $this->state;
69
    }
70
71
    public function getPostalCode(): string
72
    {
73
        return $this->postalCode;
74
    }
75
76
    public function getCountry(): string
77
    {
78
        return $this->country;
79
    }
80
81
    public function getPhone(): string
82
    {
83
        return $this->phone;
84
    }
85
}
86