ArrayHelper   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 0
cbo 0
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A fillWithDefaultValue() 0 7 1
1
<?php
2
namespace Monitor\Utils;
3
4
class ArrayHelper
5
{
6
    
7
    /**
8
     * Fill array with concret value when can't find same key in $arrayTofill as in $struct array
9
     *
10
     * @param  array $struct
11
     * @param  array $arrayToFill
12
     * @param  int   $value
13
     * @return array $arrayMerged
14
     */
15
    public function fillWithDefaultValue(array $struct, array $arrayToFill, $value = 0)
16
    {
17
        $arrayDiff = array_diff($struct, $arrayToFill);
18
        $arrayDiffFilled = array_fill_keys($arrayDiff, $value);
19
        $arrayMerged = array_merge($arrayDiffFilled, $arrayToFill);
20
        return $arrayMerged;
21
    }
22
}
23