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; |
12
|
|
|
|
13
|
|
|
use hiqdev\php\billing\action\UsageInterval; |
14
|
|
|
use hiqdev\php\billing\bill\Bill; |
15
|
|
|
use hiqdev\php\billing\bill\BillInterface; |
16
|
|
|
use hiqdev\php\billing\customer\CustomerInterface; |
17
|
|
|
use hiqdev\php\billing\plan\PlanInterface; |
18
|
|
|
use hiqdev\php\billing\target\TargetInterface; |
19
|
|
|
use hiqdev\php\billing\type\TypeInterface; |
|
|
|
|
20
|
|
|
use hiqdev\php\units\QuantityInterface; |
21
|
|
|
use Money\Money; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @author Andrii Vasyliev <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
class Generalizer implements GeneralizerInterface |
27
|
1 |
|
{ |
28
|
|
|
public function createBill(ChargeInterface $charge): BillInterface |
29
|
1 |
|
{ |
30
|
1 |
|
$bill = new Bill( |
31
|
1 |
|
null, |
32
|
1 |
|
$this->generalizeType($charge), |
33
|
1 |
|
$this->generalizeTime($charge), |
34
|
1 |
|
$this->generalizeSum($charge), |
35
|
1 |
|
$this->generalizeQuantity($charge), |
36
|
1 |
|
$this->generalizeCustomer($charge), |
37
|
1 |
|
$this->generalizeTarget($charge), |
38
|
1 |
|
$this->generalizePlan($charge), |
39
|
|
|
[$charge], |
40
|
|
|
); |
41
|
|
|
|
42
|
1 |
|
$bill->setUsageInterval($this->generalizeUsageInterval($charge)); |
43
|
|
|
|
44
|
1 |
|
return $bill; |
45
|
|
|
} |
46
|
|
|
|
47
|
1 |
|
public function generalizeType(ChargeInterface $charge): TypeInterface |
48
|
|
|
{ |
49
|
1 |
|
return $charge->getType(); |
50
|
|
|
} |
51
|
|
|
|
52
|
1 |
|
public function generalizeTime(ChargeInterface $charge): \DateTimeImmutable |
53
|
|
|
{ |
54
|
1 |
|
return $charge->getAction()->getTime(); |
55
|
|
|
} |
56
|
|
|
|
57
|
1 |
|
public function generalizeSum(ChargeInterface $charge): Money |
58
|
|
|
{ |
59
|
1 |
|
return $charge->getSum()->negative(); |
60
|
|
|
} |
61
|
|
|
|
62
|
1 |
|
public function generalizeQuantity(ChargeInterface $charge): QuantityInterface |
63
|
|
|
{ |
64
|
1 |
|
return $charge->getUsage(); |
65
|
|
|
} |
66
|
|
|
|
67
|
1 |
|
public function generalizeCustomer(ChargeInterface $charge): CustomerInterface |
68
|
|
|
{ |
69
|
1 |
|
return $charge->getAction()->getCustomer(); |
70
|
|
|
} |
71
|
|
|
|
72
|
1 |
|
public function generalizeTarget(ChargeInterface $charge): TargetInterface |
73
|
|
|
{ |
74
|
1 |
|
return $charge->getTarget(); |
75
|
|
|
} |
76
|
|
|
|
77
|
17 |
|
public function generalizePlan(ChargeInterface $charge): ?PlanInterface |
78
|
|
|
{ |
79
|
17 |
|
return $charge->getPrice()->getPlan(); |
80
|
|
|
} |
81
|
|
|
|
82
|
17 |
|
public function specializeType(TypeInterface $first, TypeInterface $other): TypeInterface |
83
|
|
|
{ |
84
|
17 |
|
return $first; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function specializeTarget(TargetInterface $first, TargetInterface $other): TargetInterface |
88
|
|
|
{ |
89
|
|
|
return $first; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
private function generalizeUsageInterval(ChargeInterface $charge): UsageInterval |
93
|
|
|
{ |
94
|
|
|
return $charge->getAction()->getUsageInterval(); |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths