ParamsResolver::resolveParams()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
c 0
b 0
f 0
rs 9.2
cc 4
eloc 12
nc 4
nop 2
1
<?php
2
namespace DICIT\Util;
3
4
use DICIT\Container;
5
6
class ParamsResolver
7
{
8
    /**
9
     * Resolve the params of an array
10
     *
11
     * @param array $params
12
     * @return array
13
     */
14
    public static function resolveParams(Container $container, $params)
15
    {
16
        $resolvedParams = array();
17
        foreach($params as $key=>$param) {
18
            $resolvedParam = null;
0 ignored issues
show
Unused Code introduced by
$resolvedParam is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
19
            if (is_array($param)) {
20
                $resolvedParam = self::resolveParams($container, $param);
21
            } else if (is_string($param)){
22
                $resolvedParam = $container->resolve($param);
23
            } else {
24
                $resolvedParam = $param;
25
            }
26
            $resolvedParams[$key] = $resolvedParam;
27
        }
28
        return $resolvedParams;
29
    }
30
}
31