Passed
Push — suppliers ( d07ac7...1b3b2e )
by Laurent
01:23
created

Supplier::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 15
c 1
b 0
f 0
nc 1
nop 15
dl 0
loc 32
rs 9.7666

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 $name;
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 $contact;
30
    private string $cellphone;
31
    private string $familyLog;
32
    private int $delayDelivery;
33
    private array $orderDays;
34
    private bool $active;
35
36
    public function __construct(
37
        string $uuid,
38
        string $name,
39
        string $address,
40
        string $zipCode,
41
        string $town,
42
        string $country,
43
        string $phone,
44
        string $facsimile,
45
        string $email,
46
        string $contact,
47
        string $cellphone,
48
        string $familyLog,
49
        int $delayDelivery,
50
        array $orderDays,
51
        bool $active = true
52
    ) {
53
        $this->uuid = $uuid;
54
        $this->name = $name;
55
        $this->address = $address;
56
        $this->zipCode = $zipCode;
57
        $this->town = $town;
58
        $this->country = $country;
59
        $this->phone = $phone;
60
        $this->facsimile = $facsimile;
61
        $this->email = $email;
62
        $this->contact = $contact;
63
        $this->cellphone = $cellphone;
64
        $this->familyLog = $familyLog;
65
        $this->delayDelivery = $delayDelivery;
66
        $this->orderDays = $orderDays;
67
        $this->active = $active;
68
    }
69
70
    public function uuid(): string
71
    {
72
        return $this->uuid;
73
    }
74
75
    public function name(): string
76
    {
77
        return $this->name;
78
    }
79
80
    public function fullAddress(): string
81
    {
82
        return ContactAddress::fromArray([$this->address, $this->zipCode, $this->town, $this->country])->getValue();
83
    }
84
85
    public function phone(): string
86
    {
87
        return $this->phone;
88
    }
89
90
    public function facsimile(): string
91
    {
92
        return $this->facsimile;
93
    }
94
95
    public function email(): string
96
    {
97
        return $this->email;
98
    }
99
100
    public function contact(): string
101
    {
102
        return $this->contact;
103
    }
104
105
    public function cellphone(): string
106
    {
107
        return $this->cellphone;
108
    }
109
110
    public function familyLog(): string
111
    {
112
        return $this->familyLog;
113
    }
114
115
    public function delayDelivery(): int
116
    {
117
        return $this->delayDelivery;
118
    }
119
120
    public function orderDays(): array
121
    {
122
        return $this->orderDays;
123
    }
124
125
    public function isActive(): bool
126
    {
127
        return $this->active;
128
    }
129
}
130