Total Complexity | 11 |
Total Lines | 63 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
8 | class Node |
||
9 | { |
||
10 | private mixed $state; |
||
11 | private string $id; |
||
12 | private ?Node $parent = null; |
||
13 | private float | int $gScore; |
||
14 | private float | int $hScore; |
||
15 | |||
16 | /** |
||
17 | * @param mixed $state The state refers to the actual user data that represents a node in the user's business logic. |
||
18 | */ |
||
19 | 40 | public function __construct(mixed $state) |
|
20 | { |
||
21 | 40 | $this->state = $state; |
|
22 | 40 | $this->id = $state instanceof NodeIdentifierInterface ? $state->getUniqueNodeId() : serialize($state); |
|
23 | 40 | } |
|
24 | |||
25 | /** |
||
26 | * @return mixed Returns the state, which is the user data that represents a node in the user's business logic. |
||
27 | */ |
||
28 | 13 | public function getState(): mixed |
|
29 | { |
||
30 | 13 | return $this->state; |
|
31 | } |
||
32 | |||
33 | 14 | public function getId(): string |
|
34 | { |
||
35 | 14 | return $this->id; |
|
36 | } |
||
37 | |||
38 | 10 | public function setParent(Node $parent): void |
|
41 | 10 | } |
|
42 | |||
43 | 13 | public function getParent(): ?Node |
|
44 | { |
||
45 | 13 | return $this->parent; |
|
46 | } |
||
47 | |||
48 | 9 | public function getF(): float | int |
|
49 | { |
||
50 | 9 | return $this->getG() + $this->getH(); |
|
51 | } |
||
52 | |||
53 | 19 | public function setG(float | int $score): void |
|
54 | { |
||
55 | 19 | $this->gScore = $score; |
|
56 | 19 | } |
|
57 | |||
58 | 16 | public function getG(): float | int |
|
61 | } |
||
62 | |||
63 | 19 | public function setH(float | int $score): void |
|
64 | { |
||
65 | 19 | $this->hScore = $score; |
|
66 | 19 | } |
|
67 | |||
68 | 15 | public function getH(): float | int |
|
71 | } |
||
72 | } |
||
73 |