| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 37 | public function interpret(BillContext $context): float |
||
| 38 | { |
||
| 39 | if (!$this->isValid($context)) { |
||
| 40 | return 0.0; |
||
| 41 | } |
||
| 42 | $bill = 0; |
||
| 43 | \preg_match(sprintf('/^%s$/', self::EXPRESSION), $context->getStructure(), $matches); |
||
| 44 | |||
| 45 | $amount = $context->getAmount(); |
||
| 46 | $billPerStep = $matches[1]; |
||
| 47 | $step = $matches[2]; |
||
| 48 | |||
| 49 | while ($amount > 0) { |
||
| 50 | $bill += $billPerStep; |
||
| 51 | $amount -= $step; |
||
| 52 | } |
||
| 53 | |||
| 54 | return $bill; |
||
| 55 | } |
||
| 57 |