Conditions | 1 |
Paths | 1 |
Total Lines | 20 |
Code Lines | 0 |
Lines | 0 |
Ratio | 0 % |
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 |
||
11 | public function __construct( |
||
12 | string $target, |
||
13 | string $though, |
||
14 | bool $cascade = true, |
||
15 | bool $nullable = false, |
||
16 | string $innerKey = null, |
||
17 | string $outerKey = '{parentRole}_{innerKey}', |
||
18 | array $where = [], |
||
19 | array $orderBy = [], |
||
20 | string $thoughInnerKey = '{sourceRole}_{innerKey}', |
||
21 | string $thoughOuterKey = '{targetRole}_{outerKey}', |
||
22 | array $thoughWhere = [], |
||
23 | bool $fkCreate = true, |
||
24 | #[ExpectedValues(values: ['NO ACTION', 'CASCADE', 'SET NULL'])] |
||
25 | string $fkAction = 'SET NULL', |
||
26 | bool $indexCreate = true, |
||
27 | #[ExpectedValues(values: ['lazy', 'eager'])] |
||
28 | string $load = 'lazy', |
||
29 | // Inverse $inverse = null, // can be uncommented for compatibility with php 8.1 |
||
30 | ) { |
||
31 | } |
||
33 |