TraverseBranchContext::getStart()   A
last analyzed

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
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Smoren\GraphTools\Structs;
4
5
use Smoren\GraphTools\Models\Interfaces\VertexInterface;
6
use Smoren\GraphTools\Structs\Interfaces\TraverseBranchContextInterface;
7
8
/**
9
 * Traverse branch context implementation
10
 * @author Smoren <[email protected]>
11
 */
12
class TraverseBranchContext implements TraverseBranchContextInterface
13
{
14
    /**
15
     * @var int current branch index
16
     */
17
    protected int $index;
18
    /**
19
     * @var int|null parent branch index
20
     */
21
    protected ?int $parentIndex;
22
    /**
23
     * @var VertexInterface vertex instance which started current branch
24
     */
25
    protected VertexInterface $start;
26
27
    /**
28
     * TraverseBranchContext constructor
29
     * @param int $index current branch index
30
     * @param int|null $parentIndex parent branch index
31
     * @param VertexInterface $start vertex instance which started current branch
32
     */
33
    public function __construct(
34
        int $index,
35
        ?int $parentIndex,
36
        VertexInterface $start
37
    ) {
38
        $this->index = $index;
39
        $this->parentIndex = $parentIndex;
40
        $this->start = $start;
41
    }
42
43
    /**
44
     * @inheritDoc
45
     */
46
    public function getIndex(): int
47
    {
48
        return $this->index;
49
    }
50
51
    /**
52
     * @inheritDoc
53
     */
54
    public function getParentIndex(): ?int
55
    {
56
        return $this->parentIndex;
57
    }
58
59
    /**
60
     * @inheritDoc
61
     */
62
    public function getStart(): VertexInterface
63
    {
64
        return $this->start;
65
    }
66
}
67