Completed
Push — master ( efd5b5...1cc014 )
by Andrii
02:16
created

FormulaChargeModifierTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 19
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A modifyCharge() 0 4 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;
12
13
use hiqdev\php\billing\action\ActionInterface;
14
use hiqdev\php\billing\charge\ChargeInterface;
15
use hiqdev\php\billing\formula\FormulaInterface;
16
17
/**
18
 * Price with formula
19
 * Provides charge modification (recalculation) with formula.
20
 *
21
 * @author Andrii Vasyliev <[email protected]>
22
 */
23
trait FormulaChargeModifierTrait
24
{
25
    /**
26
     * @var ChargeModifier|null
27
     */
28
    protected $formula;
29
30
    /**
31
     * Calculate additional charges.
32
     *
33
     * @param ActionInterface $action
34
     * @param ChargeInterface $charge
35
     * @return ChargeInterface[] calculated charges
36
     */
37
    public function modifyCharge(ChargeInterface $charge, ActionInterface $action): array
38
    {
39
        return $formula ? $formula->modifyCharge($charge, $action) : [];
0 ignored issues
show
Bug introduced by
The variable $formula does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
40
    }
41
}
42