Passed
Pull Request — develop_3.0 (#495)
by Adrien
02:45
created

Row::setStyle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
crap 2
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 86
    public function __construct(array $cells, $style)
27
    {
28
        $this
29 86
            ->setCells($cells)
30 86
            ->setStyle($style);
31 86
    }
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 86
    public function setCells(array $cells)
46
    {
47 86
        $this->cells = [];
48 86
        foreach ($cells as $cell) {
49 83
            $this->addCell($cell);
50
        }
51
52 86
        return $this;
53
    }
54
55
    /**
56
     * @return Style
57
     */
58 61
    public function getStyle()
59
    {
60 61
        return $this->style;
61
    }
62
63
    /**
64
     * @param Style|null $style
65
     * @return Row
66
     */
67 86
    public function setStyle($style)
68
    {
69 86
        $this->style = $style ?: new Style();
70
71 86
        return $this;
72
    }
73
74
    /**
75
     * @param Cell $cell
76
     * @return Row
77
     */
78 84
    public function addCell(Cell $cell)
79
    {
80 84
        $this->cells[] = $cell;
81
82 84
        return $this;
83
    }
84
}
85