예제 #1
0
파일: Route.php 프로젝트: rmhdev/cercanias
 /**
  * @param Station $station
  * @throws \Cercanias\Exception\DuplicateKeyException
  */
 public function addStation(Station $station)
 {
     if ($this->hasStation($station->getId())) {
         throw new DuplicateKeyException("Station id already exists");
     }
     $this->stations[$station->getId()] = $station;
 }
예제 #2
0
 /**
  * @param Station $departure
  * @param Station $destination
  * @param null $transfer
  * @throws \Cercanias\Exception\InvalidArgumentException
  */
 public function __construct(Station $departure, Station $destination, $transfer = null)
 {
     if ($departure->getRouteId() !== $destination->getRouteId()) {
         throw new InvalidArgumentException("Stations must have the same RouteId");
     }
     $this->departure = $departure;
     $this->destination = $destination;
     $this->setTransfer($transfer);
     $this->trips = array();
     $this->hasTransfer = false;
 }
예제 #3
0
 public function testGetRouteId()
 {
     $station = new Station(1, "Irun", "61");
     $this->assertEquals("61", $station->getRouteId());
     $this->assertInternalType("string", $station->getRouteId());
 }