| Total Complexity | 6 |
| Total Lines | 65 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 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 | 41 | public function __construct($value) |
|
| 35 | 41 | } |
|
| 36 | |||
| 37 | /** |
||
| 38 | * Check if two vertices are equal |
||
| 39 | * |
||
| 40 | * @param VertexInterface $other - other vertex to be compared |
||
| 41 | */ |
||
| 42 | 30 | public function equals(?VertexInterface $other = null): bool |
|
| 43 | { |
||
| 44 | 30 | return !is_null($other) && $this->hash == $other->getHash(); |
|
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Get the vertex hash |
||
| 49 | * |
||
| 50 | * @return string |
||
| 51 | */ |
||
| 52 | 40 | public function getHash(): string |
|
| 53 | { |
||
| 54 | 40 | return $this->hash; |
|
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Get the vertex value |
||
| 59 | * |
||
| 60 | * @return mixed |
||
| 61 | */ |
||
| 62 | 2 | public function getValue() |
|
| 63 | { |
||
| 64 | 2 | return $this->value; |
|
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Get the vertex string representation |
||
| 69 | * |
||
| 70 | * @return string |
||
| 71 | */ |
||
| 72 | 12 | public function __toString(): string |
|
| 75 | } |
||
| 76 | } |
||
| 77 |