/**
  * @param array $map
  * @param array $position
  * @param array $actions
  *
  * @dataProvider invalidNavigateDataProvider
  *
  * @expectedException \InvalidArgumentException
  */
 public function test_navigate_with_itinerary_outside_of_map(array $map, array $position, array $actions)
 {
     list($x, $y) = $map;
     $this->instance->map($x, $y);
     list($x, $y, $d) = $position;
     $this->instance->initialPosition($x, $y, $d);
     $this->instance->navigate($actions);
 }
USAGE;
    exit($errorMessage ? 1 : 0);
}
/*
 * Start script execution
 */
if ($argc !== 2 || !file_exists($argv[1])) {
    sendRover_echoUsage('parameters missing or invalid');
}
$config = (require $argv[1]);
if (!sendRover_validateConfig($config)) {
    sendRover_echoUsage('Config is not valid');
}
list($mapX, $mapY) = $config['map'];
$i = 1;
foreach ($config['rovers'] as $roverConfig) {
    $rover = new Rover();
    try {
        $rover->map($mapX, $mapY);
        list($x, $y, $direction) = $roverConfig['start'];
        $rover->initialPosition($x, $y, $direction);
        $actions = strlen($roverConfig['actions']) ? str_split($roverConfig['actions']) : array();
        $rover->navigate($actions);
        $finalPosition = $rover->getCurrentPosition();
        $direction = $rover->getCurrentDirection();
        echo "Rover #{$i} is at: ({$finalPosition['x']}, {$finalPosition['y']}) {$direction}\n";
    } catch (\InvalidArgumentException $e) {
        echo "Houston, we have a problem, Rover #{$i} got lost into space\n";
    }
    $i++;
}