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