Completed
Push — master ( 04b9b6...0cee6b )
by Andrii
04:13
created

Step::calculateFor()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 2
crap 2
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
23
    {
24 4
        $start = $min ? $min : $this;
25
26 4
        return $this->multiply($num)->add($start);
27
    }
28
}
29