Passed
Pull Request — master (#31)
by Josh
03:43
created

TableCell   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 7
c 4
b 0
f 0
lcom 1
cbo 1
dl 0
loc 33
ccs 0
cts 12
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getRow() 0 4 1
A setRow() 0 10 2
A getColspan() 0 4 2
A getRowspan() 0 4 2
1
<?php
2
3
namespace Caxy\HtmlDiff\Table;
4
5
class TableCell extends AbstractTableElement
6
{
7
    /**
8
     * @var TableRow
9
     */
10
    protected $row;
11
12
    public function getRow()
13
    {
14
        return $this->row;
15
    }
16
17
    public function setRow(TableRow $row = null)
18
    {
19
        $this->row = $row;
20
21
        if (!in_array($this, $row->getCells())) {
22
            $row->addCell($this);
0 ignored issues
show
Bug introduced by
It seems like $row is not always an object, but can also be of type null. Maybe add an additional type check?

If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:

function someFunction(A $objectMaybe = null)
{
    if ($objectMaybe instanceof A) {
        $objectMaybe->doSomething();
    }
}
Loading history...
23
        }
24
25
        return $this;
26
    }
27
28
    public function getColspan()
29
    {
30
        return $this->getAttribute('colspan') ?: 1;
31
    }
32
33
    public function getRowspan()
34
    {
35
        return $this->getAttribute('rowspan') ?: 1;
36
    }
37
}
38