Completed
Push — master ( 1f7668...7ed0a5 )
by Andrii
03:21
created

Maximum::calculateSum()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 5
ccs 0
cts 5
cp 0
crap 6
rs 10
c 0
b 0
f 0
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
use hiqdev\php\billing\charge\ChargeInterface;
14
use Money\Money;
15
16
/**
17
 * Discount maximum addon.
18
 *
19
 * @author Andrii Vasyliev <[email protected]>
20
 */
21
class Maximum extends Extremum
22
{
23
    protected static $name = 'maximum';
24
25
    public function calculateSum(ChargeInterface $charge): Money
26
    {
27
        return $this->value instanceof Money
28
            ? $this->value
29
            : $charge->getSum()->multiply($this->value*0.01)
30
        ;
31
    }
32
}
33