Passed
Push — feature/configure_company ( 5f97ab...38f251 )
by Laurent
03:30 queued 10s
created

CreateCompany::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 10
c 1
b 0
f 1
nc 1
nop 10
dl 0
loc 22
rs 9.9332

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 Domain\Administration\Company\Command;
15
16
use Domain\Common\Model\VO\EmailField;
17
use Domain\Common\Model\VO\NameField;
18
use Domain\Common\Model\VO\PhoneField;
19
use Domain\Protocol\Common\Command\CommandProtocol;
20
21
final class CreateCompany 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 $gsm;
33
34
    public function __construct(
35
        NameField $name,
36
        string $address,
37
        string $zipCode,
38
        string $town,
39
        string $country,
40
        PhoneField $phone,
41
        PhoneField $facsimile,
42
        EmailField $email,
43
        string $contact,
44
        PhoneField $gsm
45
    ) {
46
        $this->name = $name;
47
        $this->address = $address;
48
        $this->zipCode = $zipCode;
49
        $this->town = $town;
50
        $this->country = $country;
51
        $this->phone = $phone;
52
        $this->facsimile = $facsimile;
53
        $this->email = $email;
54
        $this->contact = $contact;
55
        $this->gsm = $gsm;
56
    }
57
58
    public function name(): NameField
59
    {
60
        return $this->name;
61
    }
62
63
    public function address(): string
64
    {
65
        return $this->address;
66
    }
67
68
    public function zipCode(): string
69
    {
70
        return $this->zipCode;
71
    }
72
73
    public function town(): string
74
    {
75
        return $this->town;
76
    }
77
78
    public function country(): string
79
    {
80
        return $this->country;
81
    }
82
83
    public function phone(): PhoneField
84
    {
85
        return $this->phone;
86
    }
87
88
    public function facsimile(): PhoneField
89
    {
90
        return $this->facsimile;
91
    }
92
93
    public function email(): EmailField
94
    {
95
        return $this->email;
96
    }
97
98
    public function contact(): string
99
    {
100
        return $this->contact;
101
    }
102
103
    public function gsm(): PhoneField
104
    {
105
        return $this->gsm;
106
    }
107
}
108