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

Address::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 1

Importance

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