コード例 #1
0
ファイル: FloatNumberTest.php プロジェクト: enimiste/math
 /**
  * @test
  * @dataProvider float_copy
  */
 public function check_float_copy(FN $i, $scale)
 {
     $copy = $i->copy($scale);
     $this->assertSame($i->getValue(), $copy->getValue());
     $this->assertSame($i->getOrigin(), $copy->getOrigin());
     $this->assertEquals($scale, $copy->getScale());
 }
コード例 #2
0
ファイル: Helpers.php プロジェクト: enimiste/l5-math
 /**
  * @param string|int|float|\Enimiste\Math\VO\FloatNumber $value
  *
  * @param int                                            $scale
  *
  * @return \Enimiste\Math\VO\FloatNumber
  */
 function as_float_number($value, $scale = 2)
 {
     if ($value instanceof \Enimiste\Math\VO\FloatNumber) {
         return $value->copy($scale);
     } else {
         if ($scale < 0) {
             throw new \RuntimeException('Scale should be >= 0');
         }
         if ($value instanceof \Enimiste\Math\VO\IntegerNumber) {
             $value = $value->__toString();
         }
         return new \Enimiste\Math\VO\FloatNumber($value, $scale);
     }
 }