Conditions | 4 |
Paths | 4 |
Total Lines | 23 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
29 | public function interpret(BillContext $context): float |
||
30 | { |
||
31 | if (!$this->isValid($context)) { |
||
32 | return 0.0; |
||
33 | } |
||
34 | $bill = 0.0; |
||
35 | |||
36 | $parts = preg_split(sprintf('/%s/', Expr::PIPE), $context->getStructure()); |
||
37 | for ($i = 0; $i < count($parts); $i++) { |
||
38 | $range = $this->ranges[$i]; |
||
39 | $matches = []; |
||
40 | |||
41 | \preg_match(sprintf('/^%s$/', self::EXPRESSION), $parts[$i], $matches); |
||
42 | |||
43 | $amount = $context->getAmount(); |
||
44 | |||
45 | if (RangeHelper::isInRange($range, $amount)) { |
||
46 | $bill = ($matches[1] * $amount)/ 100.00; |
||
47 | break; |
||
48 | } |
||
49 | } |
||
50 | |||
51 | return $bill; |
||
52 | } |
||
54 |