Completed
Push — master ( bf0cfa...c734e4 )
by Andrii
02:35
created

Step::calculateFor()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 4.074

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 5
cts 6
cp 0.8333
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 4
nop 3
crap 4.074
1
<?php
2
/**
3
 * PHP Billing Library
4
 *
5
 * @link      https://github.com/hiqdev/php-billing
6
 * @package   php-billing
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\billing\charge\modifiers\addons;
12
13
/**
14
 * Discount step addon.
15
 *
16
 * @author Andrii Vasyliev <[email protected]>
17
 */
18
class Step extends Discount
19
{
20
    protected static $name = 'step';
21
22 4
    public function calculateFor(int $num, ?Discount $min, ?Discount $max)
23
    {
24
        //return $this->getValue();
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
25
26 4
        $start = $min ? $min : $this;
27 4
        $value = $this->multiply($num)->add($start);
28
29 4
        if ($max && $value->compare($max) > 0) {
30
            $value = $max;
31
        }
32
33 4
        return $value->getValue();
34
    }
35
}
36