| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | public function interpret(BillContext $context): float |
||
| 29 | { |
||
| 30 | if (!$this->isValid($context)) { |
||
| 31 | return 0.0; |
||
| 32 | } |
||
| 33 | $bill = 0; |
||
| 34 | \preg_match(sprintf('/^%s$/', self::EXPRESSION), $context->getStructure(), $matches); |
||
| 35 | |||
| 36 | $amount = $context->getAmount(); |
||
| 37 | $billPerStep = $matches[1]; |
||
| 38 | $step = $matches[2]; |
||
| 39 | |||
| 40 | while($amount > 0) { |
||
| 41 | $bill += $billPerStep; |
||
| 42 | $amount -= $step; |
||
| 43 | } |
||
| 44 | |||
| 45 | return $bill; |
||
| 46 | } |
||
| 48 |