for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace JMGQ\AStar;
abstract class AbstractNode implements Node
{
private $parent;
private $children = array();
private $gScore;
private $hScore;
/**
* {@inheritdoc}
*/
public function setParent(Node $parent)
$this->parent = $parent;
}
public function getParent()
return $this->parent;
public function addChild(Node $child)
$child->setParent($this);
$this->children[] = $child;
public function getChildren()
return $this->children;
public function getF()
return $this->getG() + $this->getH();
public function setG($score)
if (!is_numeric($score)) {
throw new \InvalidArgumentException('The G value is not a number');
$this->gScore = $score;
public function getG()
return $this->gScore;
public function setH($score)
throw new \InvalidArgumentException('The H value is not a number');
$this->hScore = $score;
public function getH()
return $this->hScore;