| Conditions | 3 |
| Paths | 3 |
| Total Lines | 12 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | public function buyQuantityCalculator($maxFund, $price, $balance) |
||
| 9 | { |
||
| 10 | //calculate max fund based balance |
||
| 11 | if ($maxFund > 100) { |
||
| 12 | throw new \InvalidArgumentException('max_fund value can not be more than 100'); |
||
| 13 | } |
||
| 14 | if ($maxFund < 1) { |
||
| 15 | throw new \InvalidArgumentException('max_fund value can not be less than 1'); |
||
| 16 | } |
||
| 17 | |||
| 18 | $buyFund = ($balance * $maxFund) / 100; |
||
| 19 | return round($buyFund / $price, 8); |
||
| 20 | } |
||
| 26 | } |