Address::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 10
dl 0
loc 23
ccs 12
cts 12
cp 1
crap 1
rs 9.552
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\Company;
6
7
use Werkspot\KvkApi\Client\Profile\Company\Address\GpsCoordinates;
8
use Werkspot\KvkApi\Client\Profile\Company\Address\RijksDriehoek;
9
10
final class Address
11
{
12
    private $type;
13
14
    private $bagId;
15
16
    private $street;
17
18
    private $houseNumber;
19
20
    private $houseNumberAddition;
21
22
    private $postalCode;
23
24
    private $city;
25
26
    private $country;
27
28
    private $gpsCoordinates;
29
30
    private $rijksDriehoek;
31
32 32
    public function __construct(
33
        string $type,
34
        ?string $bagId,
35
        string $street,
36
        string $houseNumber,
37
        ?string $houseNumberAddition,
38
        string $postalCode,
39
        string $city,
40
        string $country,
41
        ?GpsCoordinates $gpsCoordinates = null,
42
        ?RijksDriehoek $rijksDriehoek =  null
43
    ) {
44 32
        $this->type = $type;
45 32
        $this->bagId = $bagId;
46 32
        $this->street = $street;
47 32
        $this->houseNumber = $houseNumber;
48 32
        $this->houseNumberAddition = $houseNumberAddition;
49 32
        $this->postalCode = $postalCode;
50 32
        $this->city = $city;
51 32
        $this->country = $country;
52 32
        $this->gpsCoordinates = $gpsCoordinates;
53 32
        $this->rijksDriehoek = $rijksDriehoek;
54 32
    }
55
56 1
    public function getType(): string
57
    {
58 1
        return $this->type;
59
    }
60
61 1
    public function getBagId(): string
62
    {
63 1
        return $this->bagId;
64
    }
65
66 1
    public function getStreet(): string
67
    {
68 1
        return $this->street;
69
    }
70
71 1
    public function getHouseNumber(): string
72
    {
73 1
        return $this->houseNumber;
74
    }
75
76 1
    public function getHouseNumberAddition()
77
    {
78 1
        return $this->houseNumberAddition;
79
    }
80
81 1
    public function getPostalCode(): string
82
    {
83 1
        return $this->postalCode;
84
    }
85
86 1
    public function getCity(): string
87
    {
88 1
        return $this->city;
89
    }
90
91 1
    public function getCountry(): string
92
    {
93 1
        return $this->country;
94
    }
95
96 1
    public function getGpsCoordinates(): ?GpsCoordinates
97
    {
98 1
        return $this->gpsCoordinates;
99
    }
100
101 1
    public function getRijksDriehoek(): ?RijksDriehoek
102
    {
103 1
        return $this->rijksDriehoek;
104
    }
105
}
106