Supplier::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 16
nc 1
nop 16
dl 0
loc 34
rs 9.7333
c 1
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
/*
6
 * This file is part of the G.L.S.R. Apps package.
7
 *
8
 * (c) Dev-Int Création <[email protected]>.
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Administration\Application\Supplier\ReadModel;
15
16
use Core\Domain\Common\Model\VO\ContactAddress;
17
18
final class Supplier
19
{
20
    private string $uuid;
21
    private string $companyName;
22
    private string $address;
23
    private string $zipCode;
24
    private string $town;
25
    private string $country;
26
    private string $phone;
27
    private string $facsimile;
28
    private string $email;
29
    private string $contactName;
30
    private string $cellphone;
31
    private string $familyLog;
32
    private int $delayDelivery;
33
    private array $orderDays;
34
    private string $slug;
35
    private bool $active;
36
37
    public function __construct(
38
        string $uuid,
39
        string $companyName,
40
        string $address,
41
        string $zipCode,
42
        string $town,
43
        string $country,
44
        string $phone,
45
        string $facsimile,
46
        string $email,
47
        string $contactName,
48
        string $cellphone,
49
        string $familyLog,
50
        int $delayDelivery,
51
        array $orderDays,
52
        string $slug,
53
        bool $active = true
54
    ) {
55
        $this->uuid = $uuid;
56
        $this->companyName = $companyName;
57
        $this->slug = $slug;
58
        $this->address = $address;
59
        $this->zipCode = $zipCode;
60
        $this->town = $town;
61
        $this->country = $country;
62
        $this->phone = $phone;
63
        $this->facsimile = $facsimile;
64
        $this->email = $email;
65
        $this->contactName = $contactName;
66
        $this->cellphone = $cellphone;
67
        $this->familyLog = $familyLog;
68
        $this->delayDelivery = $delayDelivery;
69
        $this->orderDays = $orderDays;
70
        $this->active = $active;
71
    }
72
73
    public function uuid(): string
74
    {
75
        return $this->uuid;
76
    }
77
78
    public function companyName(): string
79
    {
80
        return $this->companyName;
81
    }
82
83
    public function address(): string
84
    {
85
        return $this->address;
86
    }
87
88
    public function zipCode(): string
89
    {
90
        return $this->zipCode;
91
    }
92
93
    public function town(): string
94
    {
95
        return $this->town;
96
    }
97
98
    public function country(): string
99
    {
100
        return $this->country;
101
    }
102
103
    public function fullAddress(): string
104
    {
105
        return ContactAddress::fromArray([$this->address, $this->zipCode, $this->town, $this->country])->getValue();
106
    }
107
108
    public function phone(): string
109
    {
110
        return $this->phone;
111
    }
112
113
    public function facsimile(): string
114
    {
115
        return $this->facsimile;
116
    }
117
118
    public function email(): string
119
    {
120
        return $this->email;
121
    }
122
123
    public function contactName(): string
124
    {
125
        return $this->contactName;
126
    }
127
128
    public function cellphone(): string
129
    {
130
        return $this->cellphone;
131
    }
132
133
    public function familyLog(): string
134
    {
135
        return $this->familyLog;
136
    }
137
138
    public function delayDelivery(): int
139
    {
140
        return $this->delayDelivery;
141
    }
142
143
    public function orderDays(): array
144
    {
145
        return $this->orderDays;
146
    }
147
148
    public function slug(): string
149
    {
150
        return $this->slug;
151
    }
152
153
    public function isActive(): bool
154
    {
155
        return $this->active;
156
    }
157
}
158