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

Step   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 11
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A calculateFor() 0 6 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