Passed
Push — develop ( 6aee1f...577144 )
by Laurent
01:44
created

AbstractCompanyCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 10
dl 0
loc 22
rs 9.9332
c 0
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\Company\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 AbstractCompanyCommand implements CommandProtocol
22
{
23
    private NameField $companyName;
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
34
    public function __construct(
35
        NameField $companyName,
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 $cellPhone
45
    ) {
46
        $this->companyName = $companyName;
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->cellPhone = $cellPhone;
56
    }
57
58
    final public function companyName(): NameField
59
    {
60
        return $this->companyName;
61
    }
62
63
    final public function address(): string
64
    {
65
        return $this->address;
66
    }
67
68
    final public function zipCode(): string
69
    {
70
        return $this->zipCode;
71
    }
72
73
    final public function town(): string
74
    {
75
        return $this->town;
76
    }
77
78
    final public function country(): string
79
    {
80
        return $this->country;
81
    }
82
83
    final public function phone(): PhoneField
84
    {
85
        return $this->phone;
86
    }
87
88
    final public function facsimile(): PhoneField
89
    {
90
        return $this->facsimile;
91
    }
92
93
    final public function email(): EmailField
94
    {
95
        return $this->email;
96
    }
97
98
    final public function contact(): string
99
    {
100
        return $this->contact;
101
    }
102
103
    final public function cellPhone(): PhoneField
104
    {
105
        return $this->cellPhone;
106
    }
107
}
108