Company::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 35

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 16
dl 0
loc 35
ccs 18
cts 18
cp 1
crap 1
rs 9.36
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
3
declare(strict_types=1);
4
5
namespace Werkspot\KvkApi\Client\Profile;
6
7
use DateTime;
8
use Werkspot\KvkApi\Client\Profile\Company\Address;
9
use Werkspot\KvkApi\Client\Profile\Company\BusinessActivity;
10
use Werkspot\KvkApi\Client\Profile\Company\TradeNames;
11
12
final class Company
13
{
14
    private $kvkNumber;
15
16
    private $branchNumber;
17
18
    private $rsin;
19
20
    private $tradeNames;
21
22
    private $legalForm;
23
24
    private $businessActivities;
25
26
    private $entryInBusinessRegister;
27
28
    private $commercialActivities;
29
30
    private $nonMailingIndication;
31
32
    private $legalPerson;
33
34
    private $branch;
35
36
    private $mainBranch;
37
38
    private $employees;
39
40
    private $foundationDate;
41
42
    private $registrationDate;
43
44
    private $addresses;
45
46 35
    public function __construct(
47
        int $kvkNumber,
48
        ?string $branchNumber = null,
49
        ?int $rsin = null,
50
        TradeNames $tradeNames,
51
        ?string $legalForm,
52
        ?array $businessActivities = null,
53
        bool $entryInBusinessRegister,
54
        bool $commercialActivities,
55
        bool $nonMailingIndication,
56
        bool $legalPerson,
57
        bool $branch,
58
        bool $mainBranch,
59
        ?int $employees,
60
        DateTime $foundationDate,
61
        DateTime $registrationDate,
62
        ?array $addresses = null
63
    ) {
64 35
        $this->kvkNumber = $kvkNumber;
65 35
        $this->branchNumber = $branchNumber;
66 35
        $this->rsin = $rsin;
67 35
        $this->tradeNames = $tradeNames;
68 35
        $this->legalForm = $legalForm;
69 35
        $this->businessActivities = $businessActivities;
70 35
        $this->entryInBusinessRegister = $entryInBusinessRegister;
71 35
        $this->commercialActivities = $commercialActivities;
72 35
        $this->nonMailingIndication = $nonMailingIndication;
73 35
        $this->legalPerson = $legalPerson;
74 35
        $this->branch = $branch;
75 35
        $this->mainBranch = $mainBranch;
76 35
        $this->employees = $employees;
77 35
        $this->foundationDate = $foundationDate;
78 35
        $this->registrationDate = $registrationDate;
79 35
        $this->addresses = $addresses;
80 35
    }
81
82 34
    public function getKvkNumber(): int
83
    {
84 34
        return $this->kvkNumber;
85
    }
86
87 2
    public function getBranchNumber(): ?string
88
    {
89 2
        return $this->branchNumber;
90
    }
91
92 2
    public function getRsin(): ?int
93
    {
94 2
        return $this->rsin;
95
    }
96
97 2
    public function getTradeNames(): TradeNames
98
    {
99 2
        return $this->tradeNames;
100
    }
101
102 2
    public function getLegalForm(): string
103
    {
104 2
        return $this->legalForm;
105
    }
106
107
    /**
108
     * @return BusinessActivity[]
109
     */
110 2
    public function getBusinessActivities(): ?array
111
    {
112 2
        return $this->businessActivities;
113
    }
114
115 2
    public function hasEntryInBusinessRegister(): bool
116
    {
117 2
        return $this->entryInBusinessRegister;
118
    }
119
120 2
    public function hasCommercialActivities(): bool
121
    {
122 2
        return $this->commercialActivities;
123
    }
124
125 2
    public function hasNonMailingIndication(): bool
126
    {
127 2
        return $this->nonMailingIndication;
128
    }
129
130 2
    public function isLegalPerson(): bool
131
    {
132 2
        return $this->legalPerson;
133
    }
134
135 2
    public function isBranch(): bool
136
    {
137 2
        return $this->branch;
138
    }
139
140 2
    public function isMainBranch(): bool
141
    {
142 2
        return $this->mainBranch;
143
    }
144
145 2
    public function getEmployees(): int
146
    {
147 2
        return $this->employees;
148
    }
149
150 2
    public function getFoundationDate(): DateTime
151
    {
152 2
        return $this->foundationDate;
153
    }
154
155 2
    public function getRegistrationDate(): DateTime
156
    {
157 2
        return $this->registrationDate;
158
    }
159
160
    /**
161
     * @return Address[]
162
     */
163 2
    public function getAddresses(): ?array
164
    {
165 2
        return $this->addresses;
166
    }
167
}
168