/** * @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; }
/** * @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; }
public function testGetRouteId() { $station = new Station(1, "Irun", "61"); $this->assertEquals("61", $station->getRouteId()); $this->assertInternalType("string", $station->getRouteId()); }