Passed
Push — master ( 7cd6c5...dd963e )
by Laurens
04:05
created

Company::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 35
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 1

Importance

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