Conditions | 1 |
Paths | 1 |
Total Lines | 21 |
Code Lines | 18 |
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 createAssocationFromNavigationProperty( |
||
12 | TEntityTypeType $principalType, |
||
13 | TEntityTypeType $dependentType, |
||
14 | TNavigationPropertyType $principalNavigationProperty, |
||
15 | TNavigationPropertyType $dependentNavigationProperty = null, |
||
16 | $principalMultiplicity, |
||
|
|||
17 | $dependentMultiplicity, |
||
18 | array $principalConstraintProperty = null, |
||
19 | array $dependentConstraintProperty = null |
||
20 | ) { |
||
21 | return parent::createAssocationFromNavigationProperty( |
||
22 | $principalType, |
||
23 | $dependentType, |
||
24 | $principalNavigationProperty, |
||
25 | $dependentNavigationProperty, |
||
26 | $principalMultiplicity, |
||
27 | $dependentMultiplicity, |
||
28 | $principalConstraintProperty, |
||
29 | $dependentConstraintProperty |
||
30 | ); |
||
31 | } |
||
32 | |||
38 |
If you place a parameter with a default value before a parameter with a default value, the default value of the first parameter will never be used as it will always need to be passed anyway: