Passed
Push — feature-family-log ( d36cb7...455fa6 )
by Laurent
06:20
created

Supplier::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 35
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 17
nc 1
nop 16
dl 0
loc 35
rs 9.7
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 Administration\Domain\FamilyLog\Model\FamilyLog;
17
use Core\Domain\Common\Model\VO\ContactAddress;
18
19
final class Supplier
20
{
21
    public string $uuid;
22
    public string $name;
23
    public string $address;
24
    public string $zipCode;
25
    public string $town;
26
    public string $country;
27
    public string $phone;
28
    public string $facsimile;
29
    public string $email;
30
    public string $contact;
31
    public string $cellphone;
32
    public FamilyLog $familyLog;
33
    public string $familyLogId;
34
    public int $delayDelivery;
35
    public array $orderDays;
36
    public string $slug;
37
    public bool $active;
38
39
    public function __construct(
40
        string $uuid,
41
        string $name,
42
        string $address,
43
        string $zipCode,
44
        string $town,
45
        string $country,
46
        string $phone,
47
        string $facsimile,
48
        string $email,
49
        string $contact,
50
        string $cellphone,
51
        FamilyLog $familyLog,
52
        int $delayDelivery,
53
        array $orderDays,
54
        string $slug,
55
        bool $active = true
56
    ) {
57
        $this->uuid = $uuid;
58
        $this->name = $name;
59
        $this->slug = $slug;
60
        $this->address = $address;
61
        $this->zipCode = $zipCode;
62
        $this->town = $town;
63
        $this->country = $country;
64
        $this->phone = $phone;
65
        $this->facsimile = $facsimile;
66
        $this->email = $email;
67
        $this->contact = $contact;
68
        $this->cellphone = $cellphone;
69
        $this->familyLog = $familyLog;
70
        $this->familyLogId = $familyLog->uuid();
71
        $this->delayDelivery = $delayDelivery;
72
        $this->orderDays = $orderDays;
73
        $this->active = $active;
74
    }
75
76
    public function fullAddress(): string
77
    {
78
        return ContactAddress::fromArray([$this->address, $this->zipCode, $this->town, $this->country])->getValue();
79
    }
80
}
81