1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace hiqdev\php\billing\charge\derivative; |
4
|
|
|
|
5
|
|
|
use hiqdev\php\billing\action\ActionInterface; |
6
|
|
|
use hiqdev\php\billing\bill\BillInterface; |
7
|
|
|
use hiqdev\php\billing\charge\ChargeInterface; |
8
|
|
|
use hiqdev\php\billing\price\PriceInterface; |
9
|
|
|
use hiqdev\php\billing\target\TargetInterface; |
10
|
|
|
use hiqdev\php\billing\type\TypeInterface; |
11
|
|
|
use hiqdev\php\units\QuantityInterface; |
12
|
|
|
use Money\Money; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class ChargeDerivativeQuery |
16
|
|
|
* |
17
|
|
|
* @author Dmytro Naumenko <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
final class ChargeDerivativeQuery implements ChargeDerivativeQueryInterface |
20
|
|
|
{ |
21
|
|
|
private $changed = []; |
22
|
|
|
|
23
|
|
|
public function get(string $name, $default = null) |
24
|
|
|
{ |
25
|
|
|
return $this->isChanged($name) |
26
|
|
|
? $this->changed[$name] |
27
|
|
|
: $default; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function changeId($id): ChargeDerivativeQueryInterface |
31
|
|
|
{ |
32
|
|
|
$this->changed['id'] = $id; |
33
|
|
|
|
34
|
|
|
return $this; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function changeType(TypeInterface $type): ChargeDerivativeQueryInterface |
38
|
|
|
{ |
39
|
|
|
$this->changed['type'] = $type; |
40
|
|
|
|
41
|
|
|
return $this; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function changeTarget(TargetInterface $target): ChargeDerivativeQueryInterface |
45
|
|
|
{ |
46
|
|
|
$this->changed['target'] = $target; |
47
|
|
|
|
48
|
|
|
return $this; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function changeAction(ActionInterface $action): ChargeDerivativeQueryInterface |
52
|
|
|
{ |
53
|
|
|
$this->changed['action'] = $action; |
54
|
|
|
|
55
|
|
|
return $this; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function changePrice(PriceInterface $price): ChargeDerivativeQueryInterface |
59
|
|
|
{ |
60
|
|
|
$this->changed['price'] = $price; |
61
|
|
|
|
62
|
|
|
return $this; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function changeUsage(QuantityInterface $quantity): ChargeDerivativeQueryInterface |
66
|
|
|
{ |
67
|
|
|
$this->changed['usage'] = $quantity; |
68
|
|
|
|
69
|
|
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function changeSum(Money $sum): ChargeDerivativeQueryInterface |
73
|
|
|
{ |
74
|
|
|
$this->changed['sum'] = $sum; |
75
|
|
|
|
76
|
|
|
return $this; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function changeBill(BillInterface $bill): ChargeDerivativeQueryInterface |
80
|
|
|
{ |
81
|
|
|
$this->changed['bill'] = $bill; |
82
|
|
|
|
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function changeComment(?string $comment): ChargeDerivativeQueryInterface |
87
|
|
|
{ |
88
|
|
|
$this->changed['comment'] = $comment; |
89
|
|
|
|
90
|
|
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function changeParent(?ChargeInterface $charge): ChargeDerivativeQueryInterface |
94
|
|
|
{ |
95
|
|
|
$this->changed['charge'] = $charge; |
96
|
|
|
|
97
|
|
|
return $this; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function isChanged(string $field): bool |
101
|
|
|
{ |
102
|
|
|
return isset($this->changed[$field]); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function getParent(): ?ChargeInterface |
106
|
|
|
{ |
107
|
|
|
return $this->get('parent'); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function getId() |
111
|
|
|
{ |
112
|
|
|
return $this->get('id'); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function getUsage(): ?QuantityInterface |
116
|
|
|
{ |
117
|
|
|
return $this->get('usage'); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function getType(): ?TypeInterface |
121
|
|
|
{ |
122
|
|
|
return $this->get('type'); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function getComment(): ?string |
126
|
|
|
{ |
127
|
|
|
return $this->get('comment'); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function getSum(): ?Money |
131
|
|
|
{ |
132
|
|
|
return $this->get('sum'); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
public function getAction(): ?ActionInterface |
136
|
|
|
{ |
137
|
|
|
return $this->get('action'); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
public function getBill(): ?BillInterface |
141
|
|
|
{ |
142
|
|
|
return $this->get('bill'); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
public function getPrice(): ?PriceInterface |
146
|
|
|
{ |
147
|
|
|
return $this->get('price'); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
public function getTarget(): ?TargetInterface |
151
|
|
|
{ |
152
|
|
|
return $this->get('target'); |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
|