Issues (6)

src/Node/Node.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace JMGQ\AStar\Node;
4
5
/**
6
 * @template TState
7
 * @internal
8
 */
9
class Node
10
{
11
    /** @var TState */
0 ignored issues
show
The type JMGQ\AStar\Node\TState was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
    private mixed $state;
13
    private string $id;
14
    /** @var Node<TState> | null  */
15
    private ?Node $parent = null;
16
    /** @psalm-suppress PropertyNotSetInConstructor Reading G should fail visibly if it hasn't been previously set */
17
    private float | int $gScore;
18
    /** @psalm-suppress PropertyNotSetInConstructor Reading H should fail visibly if it hasn't been previously set */
19
    private float | int $hScore;
20
21
    /**
22
     * @param TState $state It refers to the actual user data that represents a node in the user's business logic.
23
     */
24 40
    public function __construct(mixed $state)
25
    {
26 40
        $this->state = $state;
27 40
        $this->id = $state instanceof NodeIdentifierInterface ? $state->getUniqueNodeId() : serialize($state);
28 40
    }
29
30
    /**
31
     * @return TState Returns the state, which is the user data that represents a node in the user's business logic.
32
     */
33 13
    public function getState(): mixed
34
    {
35 13
        return $this->state;
36
    }
37
38 14
    public function getId(): string
39
    {
40 14
        return $this->id;
41
    }
42
43
    /**
44
     * @param Node<TState> $parent
45
     */
46 10
    public function setParent(Node $parent): void
47
    {
48 10
        $this->parent = $parent;
49 10
    }
50
51
    /**
52
     * @return Node<TState> | null
53
     */
54 13
    public function getParent(): ?Node
55
    {
56 13
        return $this->parent;
57
    }
58
59 9
    public function getF(): float | int
60
    {
61 9
        return $this->getG() + $this->getH();
62
    }
63
64 19
    public function setG(float | int $score): void
65
    {
66 19
        $this->gScore = $score;
67 19
    }
68
69 16
    public function getG(): float | int
70
    {
71 16
        return $this->gScore;
72
    }
73
74 19
    public function setH(float | int $score): void
75
    {
76 19
        $this->hScore = $score;
77 19
    }
78
79 15
    public function getH(): float | int
80
    {
81 15
        return $this->hScore;
82
    }
83
}
84