/** * @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_has_an_origin() { $this->assertEquals('Hongkong', $this->object->origin()); }