Test Setup Failed
Pull Request — develop_3.0 (#493)
by Hura
03:41
created

Row::hasCells()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Box\Spout\Writer\Common\Entity;
4
5
use Box\Spout\Writer\Common\Entity\Style\Style;
6
use Box\Spout\Writer\Common\Manager\RowManager;
7
8
class Row
9
{
10
    /**
11
     * The cells in this row
12
     * @var Cell[]
13
     */
14
    protected $cells = [];
15
16
    /**
17
     * The row style
18
     * @var Style
19
     */
20
    protected $style;
21
22
    /**
23
     * Thw row manager
24
     * @var RowManager
25
     */
26
    protected $rowManager;
27
28
    /**
29
     * Row constructor.
30
     * @param Cell[] $cells
31
     * @param Style|null $style
32
     * @param RowManager $rowManager
33
     */
34 89
    public function __construct(array $cells, $style, RowManager $rowManager)
35
    {
36
        $this
37 89
            ->setCells($cells)
38 89
            ->setStyle($style);
39
40 89
        $this->rowManager = $rowManager;
41 89
    }
42
43
    /**
44
     * @return Cell[] $cells
45
     */
46 76
    public function getCells()
47
    {
48 76
        return $this->cells;
49
    }
50
51
    /**
52
     * @param Cell[] $cells
53
     * @return $this
54
     */
55 89
    public function setCells(array $cells)
56
    {
57 89
        $this->cells = [];
58 89
        foreach ($cells as $cell) {
59 85
            $this->addCell($cell);
60
        }
61
62 89
        return $this;
63
    }
64
65
    /**
66
     * @return Style
67
     */
68 60
    public function getStyle()
69
    {
70 60
        return $this->style;
71
    }
72
73
    /**
74
     * @param Style|null $style
75
     * @return Row
76
     */
77 89
    public function setStyle($style)
78
    {
79 89
        $this->style = $style ?: new Style();
80
81 89
        return $this;
82
    }
83
84
    /**
85
     * @param Style $style
86
     * @return Row
87
     */
88
    public function applyStyle($style)
89
    {
90
        $this->rowManager->applyStyle($this, $style);
91
92
        return $this;
93
    }
94
95
    /**
96
     * @param Cell $cell
97
     * @return Row
98
     */
99 86
    public function addCell(Cell $cell)
100
    {
101 86
        $this->cells[] = $cell;
102
103 86
        return $this;
104
    }
105
106
    /**
107
     * Returns whether a row has cells
108
     *
109
     * @return bool
110
     */
111
    public function hasCells()
112
    {
113
        return $this->rowManager->hasCells($this);
114
    }
115
116
    /**
117
     * Detect whether this row is considered empty.
118
     * An empty row has either no cells at all - or only empty cells
119
     *
120
     * @return bool
121
     */
122 30
    public function isEmpty()
123
    {
124 30
        return $this->rowManager->isEmpty($this);
125
    }
126
}
127