Conditions | 1 |
Paths | 1 |
Total Lines | 23 |
Code Lines | 0 |
Lines | 0 |
Ratio | 0 % |
Tests | 1 |
CRAP Score | 1 |
Changes | 0 |
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 |
||
9 | 1 | public function __construct( |
|
10 | public bool $isInterface, |
||
11 | public string $namespace, |
||
12 | /** |
||
13 | * @var string[] |
||
14 | */ |
||
15 | public array $modifiers, |
||
16 | public string $name, |
||
17 | public string $shortName, |
||
18 | public string $parent, |
||
19 | /** |
||
20 | * @var string[] |
||
21 | */ |
||
22 | public array $parents, |
||
23 | /** |
||
24 | * @var string[] |
||
25 | */ |
||
26 | public array $interfaces, |
||
27 | /** |
||
28 | * @var MethodConfig[] |
||
29 | */ |
||
30 | public array $methods, |
||
31 | ) { |
||
32 | } |
||
34 |