Exemplo n.º 1
0
 /** @test */
 public function should_add_two_numbers()
 {
     $command = new AddCommand(new AnyNumber(1.0407), new AnyNumber(2.406), new PositiveNumber(4));
     $total = $command->run();
     $this->assertInstanceOf('PhilipBrown\\Math\\Number', $total);
     $this->assertEquals(3.4467, $total->value());
 }
Exemplo n.º 2
0
 /**
  * Add two numbers
  *
  * @param mixed $left
  * @param mixed $right
  * @param mixed $scale
  * @return Number
  */
 public static function add($left, $right, $scale = 0)
 {
     $left = new AnyNumber($left);
     $right = new AnyNumber($right);
     $scale = new PositiveNumber($scale);
     $command = new AddCommand($left, $right, $scale);
     return $command->run();
 }