Completed
Pull Request — master (#136)
by Alex
15:37 queued 21s
created

createAssocationFromNavigationProperty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 21
rs 9.3142
cc 1
eloc 18
nc 1
nop 8

How to fix   Many Parameters   

Many Parameters

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
2
3
namespace AlgoWeb\ODataMetadata\Tests;
4
5
use AlgoWeb\ODataMetadata\MetadataManager;
6
use AlgoWeb\ODataMetadata\MetadataV3\edm\TEntityTypeType;
7
use AlgoWeb\ODataMetadata\MetadataV3\edm\TNavigationPropertyType;
8
9
class MetadataManagerDummy extends MetadataManager
10
{
11
    public function createAssocationFromNavigationProperty(
12
        TEntityTypeType $principalType,
13
        TEntityTypeType $dependentType,
14
        TNavigationPropertyType $principalNavigationProperty,
15
        TNavigationPropertyType $dependentNavigationProperty = null,
16
        $principalMultiplicity,
0 ignored issues
show
Coding Style introduced by
Parameters which have default values should be placed at the end.

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:

// $a must always be passed; it's default value is never used.
function someFunction($a = 5, $b) { }
Loading history...
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
33
    public function getNamespace()
34
    {
35
        return parent::getNamespace();
36
    }
37
}
38