Passed
Push — develop_3.0 ( 102e17...4d1d1c )
by Adrien
02:57
created

Row::getNumCells()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Box\Spout\Writer\Common\Entity;
4
5
use Box\Spout\Writer\Common\Entity\Style\Style;
6
7
class Row
8
{
9
    /**
10
     * The cells in this row
11
     * @var Cell[]
12
     */
13
    protected $cells = [];
14
15
    /**
16
     * The row style
17
     * @var Style
18
     */
19
    protected $style;
20
21
    /**
22
     * Row constructor.
23
     * @param Cell[] $cells
24
     * @param Style|null $style
25
     */
26 90
    public function __construct(array $cells, $style)
27
    {
28
        $this
29 90
            ->setCells($cells)
30 90
            ->setStyle($style);
31 90
    }
32
33
    /**
34
     * @return Cell[] $cells
35
     */
36 74
    public function getCells()
37
    {
38 74
        return $this->cells;
39
    }
40
41
    /**
42
     * @param Cell[] $cells
43
     * @return $this
44
     */
45 90
    public function setCells(array $cells)
46
    {
47 90
        $this->cells = [];
48 90
        foreach ($cells as $cell) {
49 87
            $this->addCell($cell);
50
        }
51
52 90
        return $this;
53
    }
54
55
    /**
56
     * @return Style
57
     */
58 63
    public function getStyle()
59
    {
60 63
        return $this->style;
61
    }
62
63
    /**
64
     * @param Style|null $style
65
     * @return Row
66
     */
67 90
    public function setStyle($style)
68
    {
69 90
        $this->style = $style ?: new Style();
70
71 90
        return $this;
72
    }
73
74
    /**
75
     * @param Cell $cell
76
     * @return Row
77
     */
78 88
    public function addCell(Cell $cell)
79
    {
80 88
        $this->cells[] = $cell;
81
82 88
        return $this;
83
    }
84
85
    /**
86
     * @return int
87
     */
88 67
    public function getNumCells()
89
    {
90 67
        return count($this->cells);
91
    }
92
}
93