/**
  * @param RouteSpecification $aRouteSpecification
  * @return Itinerary[] A list of itineraries that satisfy the specification. May be an empty list if no route is found.
  */
 public function fetchRoutesForSpecification(RouteSpecification $aRouteSpecification)
 {
     $transitPaths = $this->graphTraversalService->findShortestPath($aRouteSpecification->origin(), $aRouteSpecification->destination());
     $itineraries = array();
     foreach ($transitPaths as $transitPath) {
         $itineraries[] = $this->toItinerary($transitPath);
     }
     return $itineraries;
 }
 /**
  * Construct
  *
  * @param TrackingId $aTrackingId
  * @param RouteSpecification $aRouteSpecification
  */
 public function __construct(TrackingId $aTrackingId, RouteSpecification $aRouteSpecification)
 {
     //Unfortunately, doctrine does not work with ValueObjects as identifier,
     //so we have to use the string representation internally
     //@see http://www.doctrine-project.org/jira/browse/DDC-2984
     $this->trackingIdString = $aTrackingId->toString();
     //Construct is only called when the Cargo is initially created.
     //Doctrine do not call __construct when it recreates a persisted entity.
     //Therefor we can assign the origin here.
     //It will be always the same for that specific Cargo even if the RouteSpecification changes.
     $this->origin = $aRouteSpecification->origin();
     $this->routeSpecification = $aRouteSpecification;
 }
 /**
  * @test
  */
 public function it_is_not_same_value_as_route_specification_with_different_destination()
 {
     $invalidCheck = new RouteSpecification('Hongkong', 'New York');
     $this->assertFalse($this->object->sameValueAs($invalidCheck));
 }