ArrayHelper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A combineArrays() 0 4 1
A resizeArray() 0 8 2
1
<?php
2
3
namespace Pim\Bundle\ExcelConnectorBundle\Iterator;
4
5
/**
6
 * Helper methods for Excel files
7
 *
8
 * @author    Antoine Guigan <[email protected]>
9
 * @copyright 2013 Akeneo SAS (http://www.akeneo.com)
10
 * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
11
 */
12
class ArrayHelper
13
{
14
    /**
15
     * Combines array of different sizes
16
     *
17
     * @param array $keys
18
     * @param array $values
19
     *
20
     * @return array
21
     */
22
    public function combineArrays(array $keys, array $values)
23
    {
24
        return array_combine($keys, $this->resizeArray($values, count($keys)));
25
    }
26
27
    /**
28
     * Resizes an array to the specified data count
29
     *
30
     * @param array $data
31
     * @param int   $count
32
     *
33
     * @return array
34
     */
35
    protected function resizeArray(array $data, $count)
36
    {
37
        if (count($data) < $count) {
38
            $data = array_merge($data, array_fill(0, $count - count($data), ''));
39
        }
40
41
        return array_slice($data, 0, $count);
42
    }
43
}
44