Conditions | 1 |
Paths | 1 |
Total Lines | 13 |
Code Lines | 0 |
Lines | 0 |
Ratio | 0 % |
Tests | 1 |
CRAP Score | 1 |
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 |
||
8 | 8 | public function __construct( |
|
9 | public readonly string $code, |
||
10 | public readonly string $brand, |
||
11 | public readonly string $types = '', |
||
12 | public readonly string $model = '', |
||
13 | public readonly string $manufacturer = '', |
||
14 | public readonly string $country = '', |
||
15 | public readonly ?int $from = null, |
||
16 | public readonly ?int $to = null, |
||
17 | public readonly string $notes = '', |
||
18 | public readonly bool $canCompareDates = false, |
||
19 | ) |
||
20 | { |
||
21 | 8 | } |
|
38 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: