Replaced some instanceof to null checks

This commit is contained in:
Shoghi Cervantes
2014-12-09 02:22:18 +01:00
parent 306f492fc0
commit a4735eaf76
5 changed files with 35 additions and 64 deletions

View File

@ -64,7 +64,7 @@ class Position extends Vector3{
* @return bool
*/
public function isValid(){
return isset($this->level) and $this->level instanceof Level;
return $this->level !== null;
}
/**
@ -109,21 +109,6 @@ class Position extends Vector3{
return Position::fromObject(parent::getSide($side, $step), $this->level);
}
/**
* Returns the distance between two points or objects
*
* @param Vector3 $pos
*
* @return float
*/
public function distance(Vector3 $pos){
if(($pos instanceof Position) and $pos->getLevel() !== $this->getLevel()){
return PHP_INT_MAX;
}
return parent::distance($pos);
}
public function __toString(){
return "Position(level=" . ($this->isValid() ? $this->getLevel()->getName() : "null") . ",x=" . $this->x . ",y=" . $this->y . ",z=" . $this->z . ")";
}