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