Completed
Push — master ( 2f8322...f18f78 )
by Gaël
11:24
created

Address::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 9
nc 1
nop 9
dl 0
loc 21
rs 9.9666
c 1
b 0
f 1

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
namespace DansMaCulotte\LaPoste\Resources;
4
5
class Address
6
{
7
    /** @var string */
8
    public $recipient;
9
10
    /** @var string */
11
    public $premise;
12
13
    /** @var string */
14
    public $streetNumber;
15
16
    /** @var string */
17
    public $streetName;
18
19
    /** @var string */
20
    public $locality;
21
22
    /** @var string */
23
    public $postalCode;
24
25
    /** @var string */
26
    public $cedexCode;
27
28
    /** @var string */
29
    public $city;
30
31
    /** @var array */
32
    public $blockAddress;
33
34
    public function __construct(
35
        string $destinataire,
36
        string $pointRemise,
37
        string $numeroVoie,
38
        string $libelleVoie,
39
        string $lieuDit,
40
        string $codePostal,
41
        string $codeCedex,
42
        string $commune,
43
        array $blocAdresse
44
    )
45
    {
46
        $this->recipient = $destinataire;
47
        $this->streetNumber = $numeroVoie;
48
        $this->streetName = $libelleVoie;
49
        $this->premise = $pointRemise;
50
        $this->locality = $lieuDit;
51
        $this->postalCode = $codePostal;
52
        $this->cedexCode = $codeCedex;
53
        $this->city = $commune;
54
        $this->blockAddress = $blocAdresse;
55
    }
56
}
57