Failed Conditions
Pull Request — develop_3.0 (#507)
by Adrien
02:47
created

Row   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 60
ccs 14
cts 16
cp 0.875
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getCells() 0 4 1
A setCells() 0 9 2
A addCell() 0 6 1
A toArray() 0 6 1
1
<?php
2
3
namespace Box\Spout\Reader\Common\Entity;
4
5
class Row
6
{
7
    /**
8
     * The cells in this row
9
     * @var Cell[]
10
     */
11
    protected $cells = [];
12
13
    /**
14
     * Row constructor.
15
     * @param Cell[] $cells
16
     */
17 24
    public function __construct(array $cells)
18
    {
19 24
        $this->setCells($cells);
20 24
    }
21
22
    /**
23
     * @return Cell[] $cells
24
     */
25
    public function getCells()
26
    {
27
        return $this->cells;
28
    }
29
30
    /**
31
     * @param Cell[] $cells
32
     * @return $this
33
     */
34 24
    public function setCells(array $cells)
35
    {
36 24
        $this->cells = [];
37 24
        foreach ($cells as $cell) {
38 24
            $this->addCell($cell);
39
        }
40
41 24
        return $this;
42
    }
43
44
    /**
45
     * @param Cell $cell
46
     * @return Row
47
     */
48 24
    public function addCell(Cell $cell)
49
    {
50 24
        $this->cells[] = $cell;
51
52 24
        return $this;
53
    }
54
55
    /**
56
     * @return array The row values, as array
57
     */
58
    public function toArray()
59
    {
60 24
        return array_map(function (Cell $cell) {
61 24
            return $cell->getValue();
62 24
        }, $this->cells);
63
    }
64
}
65