コード例 #1
0
ファイル: Temperature.php プロジェクト: nonoliri/chomado_bot
 /**
  * コンストラクタ
  *
  * @param double $degree 摂氏度, 華氏度
  * @param string $unit "C" または "F"
  * @throws \Exception 単位が異常なとき投げる
  */
 public function __construct($degree, $unit)
 {
     switch (strtoupper($unit)) {
         case 'C':
             $this->degreeCelsius = (double) $degree;
             break;
         case 'F':
             $this->degreeCelsius = TemperatureConverter::convertFToC((double) $degree);
             break;
         default:
             throw new Exception('Unknown temperature unit was given');
     }
 }
コード例 #2
0
 /**
  * @dataProvider degreeProvider
  */
 public function testFtoC($c, $f)
 {
     $actual = TemperatureConverter::convertFToC($f);
     $this->assertEquals($c, $actual, '', 0.01);
 }