Maximum   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 5
c 2
b 0
f 1
dl 0
loc 9
ccs 3
cts 4
cp 0.75
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A calculateSum() 0 5 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-2020, 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 2
    public function calculateSum(ChargeInterface $charge): Money
26
    {
27 2
        return $this->value instanceof Money
28
            ? $this->value
29 2
            : $charge->getSum()->multiply(sprintf('%.14F', $this->value*0.01));
30
    }
31
}
32