Parameters::wrap()   B
last analyzed

Complexity

Conditions 7
Paths 5

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 7
eloc 8
c 1
b 0
f 0
nc 5
nop 2
dl 0
loc 14
rs 8.8333
1
<?php
2
namespace yentu;
3
4
class Parameters 
5
{   
6
    public static function wrap($parameters, $defaults = []) 
7
    {
8
        if(!is_array($parameters)) {
9
            return $parameters;
10
        } 
11
        
12
        foreach($defaults as $key => $value) {
13
            if(is_numeric($key) && !isset($parameters[$value])) {
14
                $parameters[$value] = null;
15
            } else if(!is_numeric($key) && !isset($parameters[$key])) {
16
                $parameters[$key] = $value;              
17
            }
18
        }        
19
        return $parameters;
20
    }
21
}
22