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

RowManager::hasCells()   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
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Box\Spout\Writer\Common\Manager;
4
5
use Box\Spout\Writer\Common\Entity\Row;
6
use Box\Spout\Writer\Common\Entity\Style\Style;
7
use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
8
9
class RowManager
10
{
11
    /**
12
     * @var StyleMerger
13
     */
14
    protected $styleMerger;
15
16
    /**
17
     * @param StyleMerger $styleMerger
18
     */
19 42
    public function __construct(StyleMerger $styleMerger)
20
    {
21 42
        $this->styleMerger = $styleMerger;
22 42
    }
23
24
    /**
25
     * Detect whether a row is considered empty.
26
     * An empty row has either no cells at all - or only one empty cell
27
     *
28
     * @param Row $row
29
     * @return bool
30
     */
31 34
    public function isEmpty(Row $row)
32
    {
33 34
        $cells = $row->getCells();
34
35 34
        return count($cells) === 0 || (count($cells) === 1 && $cells[0]->isEmpty());
36
    }
37
}
38