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

TableCell   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 5
Bugs 0 Features 1
Metric Value
wmc 7
c 5
b 0
f 1
lcom 1
cbo 1
dl 0
loc 47
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
/**
6
 * Class TableCell
7
 * @package Caxy\HtmlDiff\Table
8
 */
9
class TableCell extends AbstractTableElement
10
{
11
    /**
12
     * @var TableRow
13
     */
14
    protected $row;
15
16
    /**
17
     * @return TableRow
18
     */
19
    public function getRow()
20
    {
21
        return $this->row;
22
    }
23
24
    /**
25
     * @param TableRow|null $row
26
     *
27
     * @return $this
28
     */
29
    public function setRow(TableRow $row = null)
30
    {
31
        $this->row = $row;
32
33
        if (!in_array($this, $row->getCells())) {
34
            $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...
35
        }
36
37
        return $this;
38
    }
39
40
    /**
41
     * @return int
0 ignored issues
show
Documentation introduced by
Should the return type not be string|integer?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
42
     */
43
    public function getColspan()
44
    {
45
        return $this->getAttribute('colspan') ?: 1;
46
    }
47
48
    /**
49
     * @return int
0 ignored issues
show
Documentation introduced by
Should the return type not be string|integer?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
50
     */
51
    public function getRowspan()
52
    {
53
        return $this->getAttribute('rowspan') ?: 1;
54
    }
55
}
56