Total Complexity | 5 |
Total Lines | 65 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
10 | class Vertex implements VertexInterface |
||
11 | { |
||
12 | /** |
||
13 | * The vertex unique hash |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | private $hash; |
||
18 | |||
19 | /** |
||
20 | * The vertex value |
||
21 | * |
||
22 | * @var mixed |
||
23 | */ |
||
24 | private $value; |
||
25 | |||
26 | /** |
||
27 | * Construct a new vertex |
||
28 | * |
||
29 | * @param mixed $value - value stored in vertex |
||
30 | */ |
||
31 | 10 | public function __construct($value) |
|
35 | 10 | } |
|
36 | |||
37 | /** |
||
38 | * Check if two vertices are equal |
||
39 | * |
||
40 | * @param VertexInterface $other - other vertex to be compared |
||
41 | */ |
||
42 | 2 | public function equals(VertexInterface $other): bool |
|
43 | { |
||
44 | 2 | return $this->hash == $other->getHash(); |
|
45 | } |
||
46 | |||
47 | /** |
||
48 | * Get the vertex hash |
||
49 | * |
||
50 | * @return string |
||
51 | */ |
||
52 | 5 | public function getHash(): string |
|
53 | { |
||
54 | 5 | return $this->hash; |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * Get the vertex value |
||
59 | * |
||
60 | * @return mixed |
||
61 | */ |
||
62 | 1 | public function getValue() |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * Get the vertex string representation |
||
69 | * |
||
70 | * @return string |
||
71 | */ |
||
72 | 1 | public function __toString(): string |
|
75 | } |
||
76 | } |
||
77 |