AbstractCompany::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
c 0
b 0
f 0
nc 1
nop 11
dl 0
loc 24
rs 9.9

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 Company\Application\Company\Command;
15
16
use Core\Domain\Common\Command\CommandInterface;
17
18
abstract class AbstractCompany implements CommandInterface
19
{
20
    public ?string $uuid;
21
    private string $companyName;
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 $contactName;
30
    private string $cellPhone;
31
32
    public function __construct(
33
        string $companyName,
34
        string $address,
35
        string $zipCode,
36
        string $town,
37
        string $country,
38
        string $phone,
39
        string $facsimile,
40
        string $email,
41
        string $contactName,
42
        string $cellphone,
43
        ?string $uuid = null
44
    ) {
45
        $this->uuid = $uuid;
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->contactName = $contactName;
55
        $this->cellPhone = $cellphone;
56
    }
57
58
    final public function companyName(): string
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(): string
84
    {
85
        return $this->phone;
86
    }
87
88
    final public function facsimile(): string
89
    {
90
        return $this->facsimile;
91
    }
92
93
    final public function email(): string
94
    {
95
        return $this->email;
96
    }
97
98
    final public function contactName(): string
99
    {
100
        return $this->contactName;
101
    }
102
103
    final public function cellphone(): string
104
    {
105
        return $this->cellPhone;
106
    }
107
108
    final public function uuid(): ?string
109
    {
110
        return $this->uuid;
111
    }
112
}
113