Passed
Push — develop ( 7d2e81...61e6f0 )
by Laurent
06:22 queued 03:53
created

Company::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

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