private function safeMove(callable $moveAction)
    {
        $oldPosition = $this->position;

        try {
            return $moveAction();
        } catch (OutOfBoundsException $e) {
            $this->position = $oldPosition;

            throw $e;
        }
    }
private function safeMove(callable $moveAction)
    {
        $oldPosition = $this->position;

        try {
            return $moveAction();
        } catch (OutOfBoundsException $e) {
            $this->position = $oldPosition;

            throw $e;
        }
    }
private function safeMove ( callable $ moveAction ) { $ oldPosition = $ this -> position ; try { return $ moveAction ( ) ; } catch ( OutOfBoundsException $ e ) { $ this -> position = $ oldPosition ; throw $ e ; } }
Restores previous position if OutOfBounds error occurs.

@param callable $moveAction

@return mixed
Restores previous position if OutOfBounds error occurs .