Completed
Push — master ( fab847...ccc0a3 )
by Andrii
02:34
created

Maximum   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 9
ccs 3
cts 4
cp 0.75
rs 10
c 0
b 0
f 0
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-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 2
    public function calculateSum(ChargeInterface $charge): Money
26
    {
27 2
        return $this->value instanceof Money
28
            ? $this->value
29 2
            : $charge->getSum()->multiply($this->value*0.01)
30
        ;
31
    }
32
}
33