Vertex   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 50
c 0
b 0
f 0
wmc 7
lcom 1
cbo 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getValue() 0 4 1
A getNeighbours() 0 4 1
A addNeighbour() 0 6 2
A getIndex() 0 4 1
A setIndex() 0 4 1
1
<?php
2
/**
3
 * @copyright 2018 Aleksander Stelmaczonek <[email protected]>
4
 * @license   MIT License, see license file distributed with this source code
5
 */
6
7
namespace Koriit\PHPDeps\Graph;
8
9
class Vertex
10
{
11
    /** @var mixed Held value */
12
    private $value;
13
14
    /** @var Vertex[] */
15
    private $neighbours;
16
17
    /** @var int The index in the graph */
18
    private $index = null;
19
20
    public function __construct($value, array $neighbours = [])
21
    {
22
        $this->value = $value;
23
        $this->neighbours = $neighbours;
24
    }
25
26
    /**
27
     * @return mixed
28
     */
29
    public function getValue()
30
    {
31
        return $this->value;
32
    }
33
34
    public function getNeighbours()
35
    {
36
        return $this->neighbours;
37
    }
38
39
    /**
40
     * @param Vertex $neighbour
41
     */
42
    public function addNeighbour(Vertex $neighbour)
43
    {
44
        if (!\in_array($neighbour, $this->neighbours)) {
45
            $this->neighbours[] = $neighbour;
46
        }
47
    }
48
49
    public function getIndex()
50
    {
51
        return $this->index;
52
    }
53
54
    public function setIndex($index)
55
    {
56
        $this->index = $index;
57
    }
58
}
59