RowBuilder   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 40
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addValue() 0 6 2
A getData() 0 12 3
1
<?php
2
3
namespace Akeneo\Component\SpreadsheetParser\Xlsx;
4
5
/**
6
 * Builds a row with skipped values
7
 *
8
 * @author    Antoine Guigan <[email protected]>
9
 * @copyright 2014 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 RowBuilder
13
{
14
15
    /**
16
     *
17
     * @var array
18
     */
19
    protected $values = [];
20
21
    /**
22
     * Adds a value to the row
23
     *
24
     * @param int    $columnIndex
25
     * @param string $value
26
     */
27
    public function addValue($columnIndex, $value)
28
    {
29
        if ('' !== $value) {
30
            $this->values[$columnIndex] = $value;
31
        }
32
    }
33
34
    /**
35
     * Returns the read row
36
     *
37
     * @return array
38
     */
39
    public function getData()
40
    {
41
        $data = [];
42
        foreach ($this->values as $columnIndex => $value) {
43
            while (count($data) < $columnIndex) {
44
                $data[] = '';
45
            }
46
            $data[] = $value;
47
        }
48
49
        return $data;
50
    }
51
}
52