City::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 1
nc 1
nop 8

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 App\DTO;
4
5
use Stringable;
6
7
class City implements Stringable
8
{
9
    public function __construct(
10
        private string $name,
11
        private string $departmentCode,
12
        private string $department,
13
        private string $region,
14
        private int $inseeCode,
15
        private int $logicImmoCode,
16
        private int $papCode,
17
        private int $seLogerNeufCode
18
    ) {}
19
20
    public function getName(): string
21
    {
22
        return $this->name;
23
    }
24
25
    public function getDepartmentCode(): string
26
    {
27
        return $this->departmentCode;
28
    }
29
30
    public function getDepartment(): string
31
    {
32
        return $this->department;
33
    }
34
35
    public function getRegion(): string
36
    {
37
        return $this->region;
38
    }
39
40
    public function getInseeCode(): int
41
    {
42
        return $this->inseeCode;
43
    }
44
45
    public function getLogicImmoCode(): int
46
    {
47
        return $this->logicImmoCode;
48
    }
49
50
    public function getPapCode(): int
51
    {
52
        return $this->papCode;
53
    }
54
55
    public function getSeLogerNeufCode(): int
56
    {
57
        return $this->seLogerNeufCode;
58
    }
59
60
    public function getZipCode(): string
61
    {
62
        return $this->departmentCode . '000';
63
    }
64
65
    /**
66
     * {@inheritDoc}
67
     */
68
    public function __toString(): string
69
    {
70
        return $this->name;
71
    }
72
}
73