DetailedPlayer::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 21
ccs 11
cts 11
cp 1
rs 9.3142
cc 1
eloc 19
nc 1
nop 9
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
namespace PtrTn\Battlerite\Dto\Player;
4
5
class DetailedPlayer
6
{
7
    /**
8
     * @var string
9
     */
10
    public $type;
11
12
    /**
13
     * @var string
14
     */
15
    public $id;
16
17
    /**
18
     * @var string
19
     */
20
    public $name;
21
22
    /**
23
     * @var string
24
     */
25
    public $patchVersion;
26
27
    /**
28
     * @var string
29
     */
30
    public $shardId;
31
32
    /**
33
     * @var int
34
     */
35
    public $picture;
36
37
    /**
38
     * @var int
39
     */
40
    public $title;
41
42
    /**
43
     * @var string
44
     */
45
    public $titleId;
46
47
    /**
48
     * @var Stats
49
     */
50
    public $stats;
51
52 1
    public function __construct(
53
        string $type,
54
        string $id,
55
        string $name,
56
        string $patchVersion,
57
        string $shardId,
58
        int $picture,
59
        int $title,
60
        string $titleId,
61
        Stats $stats
62
    ) {
63 1
        $this->type = $type;
64 1
        $this->id = $id;
65 1
        $this->name = $name;
66 1
        $this->patchVersion = $patchVersion;
67 1
        $this->shardId = $shardId;
68 1
        $this->picture = $picture;
69 1
        $this->title = $title;
70 1
        $this->titleId = $titleId;
71 1
        $this->stats = $stats;
72 1
    }
73
}
74