GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( d5fbb1...8eb400 )
by Ransford
01:35
created

SteppedBillInterpreter::interpret()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 11
nc 3
nop 1
dl 0
loc 18
rs 9.9
c 0
b 0
f 0
1
<?php
2
/**
3
 * Billing Boss
4
 *
5
 * @link      https://github.com/ranskills/billing-boss-php
6
 * @copyright Copyright (c) 2018 Ransford Ako Okpoti
7
 * @license   Refer to the LICENSE distributed with this library
8
 * @since     1.0
9
 */
10
namespace BillingBoss\Interpreter;
11
12
use BillingBoss\Expr;
13
use BillingBoss\BillContext;
14
use BillingBoss\AbstractBillInterpreter;
15
16
final class SteppedBillInterpreter extends AbstractBillInterpreter
17
{
18
    private const EXPRESSION =  Expr::POSITIVE_NUMBER .
19
                                Expr::COMMA .
20
                                Expr::POSITIVE_NUMBER .
21
                                '\+';
22
23
    public function __construct()
24
    {
25
        parent::__construct(sprintf('/^%s$/', self::EXPRESSION));
26
    }
27
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
    }
47
}
48