Completed
Push — feature/configure_company ( 4609f0 )
by Laurent
08:28
created

Company::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

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

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\Model;
15
16
use Domain\Common\Model\Contact;
17
use Domain\Common\Model\ContactUuid;
18
use Domain\Common\Model\VO\ContactAddress;
19
use Domain\Common\Model\VO\EmailField;
20
use Domain\Common\Model\VO\NameField;
21
use Domain\Common\Model\VO\PhoneField;
22
23
class Company extends Contact
24
{
25
    public static function create(
26
        ContactUuid $uuid,
27
        NameField $name,
28
        string $address,
29
        string $zipCode,
30
        string $town,
31
        string $country,
32
        PhoneField $phone,
33
        PhoneField $facsimile,
34
        EmailField $email,
35
        string $contact,
36
        PhoneField $gsm
37
    ): self {
38
        return new self(
39
            $uuid,
40
            $name,
41
            ContactAddress::fromString($address, $zipCode, $town, $country),
42
            $phone,
43
            $facsimile,
44
            $email,
45
            $contact,
46
            $gsm
47
        );
48
    }
49
50
    final public function renameCompany(NameField $name): void
51
    {
52
        $this->name = $name->getValue();
53
        $this->slug = $name->slugify();
54
    }
55
}
56