Quantity   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buyQuantityCalculator() 0 12 3
A sellQuantityCalculator() 0 3 1
1
<?php
2
3
namespace Mokka\Calculator;
4
5
class Quantity
6
{
7
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
    }
21
22
    public function sellQuantityCalculator($maxSell, $price)
23
    {
24
        return ($maxSell / 100) * $price;
25
    }
26
}