Conditions | 2 |
Paths | 2 |
Total Lines | 25 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 4 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
18 | 7 | public function collect( |
|
19 | string $service, |
||
20 | string $class, |
||
21 | string $method, |
||
22 | ?array $arguments, |
||
23 | $result, |
||
24 | string $status, |
||
25 | ?object $error, |
||
26 | float $timeStart, |
||
27 | float $timeEnd |
||
28 | ): void { |
||
29 | 7 | if (!$this->isActive()) { |
|
30 | 5 | return; |
|
31 | } |
||
32 | |||
33 | 2 | $this->items[] = [ |
|
34 | 'service' => $service, |
||
35 | 'class' => $class, |
||
36 | 'method' => $method, |
||
37 | 'arguments' => $arguments, |
||
38 | 'result' => $result, |
||
39 | 'status' => $status, |
||
40 | 'error' => $error, |
||
41 | 'timeStart' => $timeStart, |
||
42 | 'timeEnd' => $timeEnd, |
||
43 | ]; |
||
60 |
This check looks for private methods that have been defined, but are not used inside the class.