Completed
Push — master ( 0710f6...44d7fb )
by Dmitry
13:11
created

ChargeDerivative   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 21 3
1
<?php
2
3
namespace hiqdev\php\billing\charge\derivative;
4
5
use hiqdev\php\billing\charge\Charge;
6
use hiqdev\php\billing\charge\ChargeInterface;
7
8
/**
9
 * Class ChargeDerivative
10
 *
11
 * @author Dmytro Naumenko <[email protected]>
12
 */
13
final class ChargeDerivative implements ChargeDerivativeInterface
14
{
15
    public function __invoke(ChargeInterface $originalCharge, ChargeDerivativeQueryInterface $query): ChargeInterface
16
    {
17
        $tempCharge = new Charge(
18
            $query->get('id', $originalCharge->getId()),
0 ignored issues
show
Bug introduced by
The method get() does not exist on hiqdev\php\billing\charg...erivativeQueryInterface. Did you maybe mean getId()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
            $query->/** @scrutinizer ignore-call */ 
19
                    get('id', $originalCharge->getId()),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
19
            $query->get('type', $originalCharge->getType()),
20
            $query->get('target', $originalCharge->getTarget()),
21
            $query->get('action', $originalCharge->getAction()),
22
            $query->get('price', $originalCharge->getPrice()),
23
            $query->get('usage', $originalCharge->getUsage()),
24
            $query->get('sum', $originalCharge->getSum()),
25
            $query->get('bill', $originalCharge->getBill())
0 ignored issues
show
Bug introduced by
The method getBill() does not exist on hiqdev\php\billing\charge\ChargeInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to hiqdev\php\billing\charge\ChargeInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
            $query->get('bill', $originalCharge->/** @scrutinizer ignore-call */ getBill())
Loading history...
26
        );
27
28
        if ($query->get('comment', $originalCharge->getComment()) !== null) {
29
            $tempCharge->setComment($query->get('comment', $originalCharge->getComment()));
30
        }
31
        if ($query->get('parent', $originalCharge->getParent()) !== null) {
32
            $tempCharge->setParent($query->get('parent', $originalCharge->getParent()));
33
        }
34
35
        return $tempCharge;
36
    }
37
}
38