Contact::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 0
c 1
b 0
f 1
dl 0
loc 15
ccs 1
cts 1
cp 1
rs 10
cc 1
nc 1
nop 13
crap 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
declare(strict_types=1);
4
5
namespace Swis\Melvin\Models;
6
7
class Contact
8
{
9 6
    public function __construct(
10
        public int $contactId,
11
        public string $firstName,
12
        public string $prefix,
13
        public string $lastName,
14
        public string $email,
15
        public string $phone,
16
        public ?string $organisation,
17
        public int $parentSituationId,
18
        public string $function,
19
        public string $publicPhone,
20
        public bool $active,
21
        public int $createdById,
22
        public int $changedById
23
    ) {
24 6
    }
25
}
26