コード例 #1
0
ファイル: AirportInfoTest.php プロジェクト: cgrandval/opencfp
 /** @test */
 public function it_can_be_constructed_from_database_row()
 {
     $airport = AirportInfo::fromData(['code' => 'RDU', 'name' => 'Raleigh/Durham (NC)', 'country' => 'USA']);
     $this->assertEquals('RDU', $airport->code);
     $this->assertEquals('Raleigh/Durham (NC)', $airport->name);
     $this->assertEquals('USA', $airport->country);
 }
コード例 #2
0
 /**
  * @param string $code the IATA Airport Code to get information for
  *
  * @return AirportInfo
  * @throws \Exception
  */
 public function withCode($code)
 {
     $airport = $this->capsule->table('airports')->where('code', $code)->first(['code', 'name', 'country']);
     if (!$airport) {
         throw new \Exception("An airport matching '{$code}' was not found.");
     }
     return AirportInfo::fromData($airport);
 }