Passed
Push — master ( 272a3b...fe3af1 )
by Josh
04:19
created

TablePosition   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 28.57%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 62
ccs 4
cts 14
cp 0.2857
rs 10
wmc 6
lcom 1
cbo 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getRow() 0 4 1
A getCell() 0 4 1
A __toString() 0 4 1
A compare() 0 8 2
A __construct() 0 5 1
1
<?php
2
3
namespace Caxy\HtmlDiff\Table;
4
5
/**
6
 * Class TablePosition.
7
 */
8
class TablePosition
9
{
10
    /**
11
     * @var int
12
     */
13
    public $row;
14
    /**
15
     * @var int
16
     */
17
    public $cell;
18
19
    /**
20
     * TablePosition constructor.
21
     *
22
     * @param int $row
23
     * @param int $cell
24
     */
25 1
    public function __construct($row, $cell)
26
    {
27 1
        $this->row = $row;
28 1
        $this->cell = $cell;
29 1
    }
30
31
    /**
32
     * @return int
33
     */
34
    public function getRow()
35
    {
36
        return $this->row;
37
    }
38
39
    /**
40
     * @return int
41
     */
42
    public function getCell()
43
    {
44
        return $this->cell;
45
    }
46
47
    /**
48
     * @return string
49
     */
50
    public function __toString()
51
    {
52
        return $this->row.':'.$this->cell;
53
    }
54
55
    /**
56
     * @param TablePosition $a
57
     * @param TablePosition $b
58
     *
59
     * @return int
60
     */
61
    public static function compare($a, $b)
62
    {
63
        if ($a->getRow() == $b->getRow()) {
64
            return $a->getCell() - $b->getCell();
65
        }
66
67
        return $a->getRow() - $b->getRow();
68
    }
69
}
70