Completed
Pull Request — master (#14)
by Fabien
15:46 queued 12:42
created

ArrayFunctions   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A arrayValuesRecursive() 0 8 2
A arrayValuesMerge() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of the FabienCrassat\CurriculumVitaeBundle Symfony bundle.
5
 *
6
 * (c) Fabien Crassat <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FabienCrassat\CurriculumVitaeBundle\Utility;
13
14
class ArrayFunctions
15
{
16
    /**
17
     * @param array $array
18
     */
19
    public function arrayValuesRecursive($array)
20
    {
21
        $result = array();
22
        foreach($array as $value) {
23
            $result = $this->arrayValuesMerge($result, $value);
24
        }
25
        return $result;
26
    }
27
28
    private function arrayValuesMerge($array, $value)
29
    {
30
        if(is_array($value)) {
31
            return array_merge($array, $this->arrayValuesRecursive($value));
32
        }
33
34
        return array_merge($array, array($value));
35
    }
36
}
37