コード例 #1
0
 /** @test */
 public function should_multiply_two_numbers()
 {
     $command = new MultiplyCommand(new AnyNumber(5.34), new AnyNumber(2.24), new PositiveNumber(4));
     $total = $command->run();
     $this->assertInstanceOf('PhilipBrown\\Math\\Number', $total);
     $this->assertEquals(11.9616, $total->value());
 }
コード例 #2
0
ファイル: Math.php プロジェクト: philipbrown/math
 /**
  * Multiply two numbers
  *
  * @param mixed $left
  * @param mixed $right
  * @param mixed $scale
  * @return Number
  */
 public static function multiply($left, $right, $scale = 0)
 {
     $left = new AnyNumber($left);
     $right = new AnyNumber($right);
     $scale = new PositiveNumber($scale);
     $command = new MultiplyCommand($left, $right, $scale);
     return $command->run();
 }