Passed
Push — master ( 5e09ea...fc5aaf )
by Ondřej
03:46
created

TupleId::getTupleIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
namespace Ivory\Value;
4
5
use Ivory\Value\Alg\ComparableWithPhpOperators;
6
use Ivory\Value\Alg\IComparable;
7
8
/**
9
 * Representation of a PostgreSQL tuple ID.
10
 *
11
 * A tuple ID identifies the physical location of the row within its table.
12
 *
13
 * The objects are immutable.
14
 *
15
 * @see https://www.postgresql.org/docs/11/datatype-oid.html
16
 */
17
class TupleId implements IComparable
18
{
19
    use ComparableWithPhpOperators;
20
21
    private $blockNumber;
22
    private $tupleIndex;
23
24
    /**
25
     * @param int $blockNumber number of block within which the row is stored
26
     * @param int $tupleIndex index with the block where the row is stored
27
     * @return TupleId
28
     */
29
    public static function fromCoordinates(int $blockNumber, int $tupleIndex): TupleId
30
    {
31
        return new TupleId($blockNumber, $tupleIndex);
32
    }
33
34
    private function __construct(int $blockNumber, int $tupleIndex)
35
    {
36
        $this->blockNumber = $blockNumber;
37
        $this->tupleIndex = $tupleIndex;
38
    }
39
40
    /**
41
     * @return int number of block within which the row is stored
42
     */
43
    public function getBlockNumber(): int
44
    {
45
        return $this->blockNumber;
46
    }
47
48
    /**
49
     * @return int index with the block where the row is stored
50
     */
51
    public function getTupleIndex(): int
52
    {
53
        return $this->tupleIndex;
54
    }
55
}
56