Passed
Pull Request — develop (#155)
by Laurent
02:14
created

CreateSupplier::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 13
nc 1
nop 13
dl 0
loc 28
rs 9.8333
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\Domain\Supplier\Command;
15
16
use Core\Domain\Common\Model\VO\EmailField;
17
use Core\Domain\Common\Model\VO\NameField;
18
use Core\Domain\Common\Model\VO\PhoneField;
19
use Core\Domain\Protocol\Common\Command\CommandProtocol;
20
21
class CreateSupplier implements CommandProtocol
22
{
23
    private NameField $name;
24
    private string $address;
25
    private string $zipCode;
26
    private string $town;
27
    private string $country;
28
    private PhoneField $phone;
29
    private PhoneField $facsimile;
30
    private EmailField $email;
31
    private string $contact;
32
    private PhoneField $cellPhone;
33
    private string $familyLogUuid;
34
    private int $delayDelivery;
35
    private array $orderDays;
36
37
    public function __construct(
38
        NameField $name,
39
        string $address,
40
        string $zipCode,
41
        string $town,
42
        string $country,
43
        PhoneField $phone,
44
        PhoneField $facsimile,
45
        EmailField $email,
46
        string $contact,
47
        PhoneField $cellPhone,
48
        string $familyLogUuid,
49
        int $delayDelivery,
50
        array $orderDays
51
    ) {
52
        $this->name = $name;
53
        $this->address = $address;
54
        $this->zipCode = $zipCode;
55
        $this->town = $town;
56
        $this->country = $country;
57
        $this->phone = $phone;
58
        $this->facsimile = $facsimile;
59
        $this->email = $email;
60
        $this->contact = $contact;
61
        $this->cellPhone = $cellPhone;
62
        $this->familyLogUuid = $familyLogUuid;
63
        $this->delayDelivery = $delayDelivery;
64
        $this->orderDays = $orderDays;
65
    }
66
67
    public function name(): NameField
68
    {
69
        return $this->name;
70
    }
71
72
    public function address(): string
73
    {
74
        return $this->address;
75
    }
76
77
    public function zipCode(): string
78
    {
79
        return $this->zipCode;
80
    }
81
82
    public function town(): string
83
    {
84
        return $this->town;
85
    }
86
87
    public function country(): string
88
    {
89
        return $this->country;
90
    }
91
92
    public function phone(): PhoneField
93
    {
94
        return $this->phone;
95
    }
96
97
    public function facsimile(): PhoneField
98
    {
99
        return $this->facsimile;
100
    }
101
102
    public function email(): EmailField
103
    {
104
        return $this->email;
105
    }
106
107
    public function contact(): string
108
    {
109
        return $this->contact;
110
    }
111
112
    public function cellPhone(): PhoneField
113
    {
114
        return $this->cellPhone;
115
    }
116
117
    public function familyLogUuid(): string
118
    {
119
        return $this->familyLogUuid;
120
    }
121
122
    public function delayDelivery(): int
123
    {
124
        return $this->delayDelivery;
125
    }
126
127
    public function orderDays(): array
128
    {
129
        return $this->orderDays;
130
    }
131
}
132