Skip to content

Commit

Permalink
Fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
sagikazarmark committed Mar 11, 2017
1 parent 264781a commit e691944
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Calculator/GmpCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ public function multiply($amount, $multiplier)
}

$resultBase = gmp_strval(gmp_mul(gmp_init($amount), gmp_init($multiplierBase)));
if ($resultBase === '0') {

if ('0' === $resultBase) {
return '0';
}

$resultLength = strlen($resultBase);
$result = substr($resultBase, 0, $resultLength - $decimalPlaces);
$result .= '.'.substr($resultBase, $resultLength - $decimalPlaces);
Expand Down
10 changes: 8 additions & 2 deletions tests/Calculator/GmpCalculatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ protected function getCalculator()
return new GmpCalculator();
}

public function testMultiplyZero()
/**
* @test
*/
public function it_multiplies_zero()
{
$this->assertSame('0', $this->getCalculator()->multiply('0', '0.8'));
}

public function testFloorZero()
/**
* @test
*/
public function it_floors_zero()
{
$this->assertSame('0', $this->getCalculator()->floor('0'));
}
Expand Down

0 comments on commit e691944

Please sign in to comment.