예제 #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();
 }