18
18
use hiqdev \php \billing \price \PriceFactory ;
19
19
use hiqdev \php \billing \price \RatePrice ;
20
20
use hiqdev \php \billing \price \SinglePrice ;
21
+ use hiqdev \php \billing \sale \SaleInterface ;
21
22
use hiqdev \php \billing \target \Target ;
22
23
use hiqdev \php \billing \tests \support \order \SimpleBilling ;
23
24
use hiqdev \php \billing \tests \support \tools \SimpleFactory ;
@@ -33,11 +34,12 @@ class FactoryBasedBuilder implements BuilderInterface
33
34
34
35
private $ plan ;
35
36
36
- private $ sale ;
37
+ private SaleInterface $ sale ;
37
38
38
39
private $ prices = [];
39
40
40
- private $ actions = [];
41
+ /** @var ActionInterface[] */
42
+ private array $ actions = [];
41
43
42
44
private $ factory ;
43
45
@@ -122,13 +124,18 @@ public function recreatePlan(string $name)
122
124
$ plan ->setPrices ($ this ->prices );
123
125
}
124
126
125
- public function buildSale (string $ target , $ plan , string $ time = null , ?string $ closeTime = null )
127
+ public function buildSale (string $ target , $ planName , string $ time = null , ?string $ closeTime = null )
128
+ {
129
+ return $ this ->createSale ($ target , $ planName , $ time , $ closeTime );
130
+ }
131
+
132
+ public function createSale (string $ target , $ planName , string $ time = null , ?string $ closeTime = null )
126
133
{
127
134
$ this ->time = $ time ;
128
135
$ this ->sale = $ this ->factory ->getSale (array_filter ([
129
136
'customer ' => $ this ->customer ,
130
137
'target ' => $ target ,
131
- 'plan ' => $ plan ,
138
+ 'plan ' => $ planName ,
132
139
'time ' => $ time ,
133
140
'closeTime ' => $ closeTime ,
134
141
]));
@@ -198,10 +205,10 @@ public function buildAction(array $data): ActionInterface
198
205
$ data ['time ' ] = $ data ['time ' ] ?? $ this ->time ;
199
206
$ data ['customer ' ] = $ data ['customer ' ] ?? $ this ->customer ;
200
207
if (!empty ($ data ['targets ' ])) {
201
- $ data ['target ' ] = $ this ->factory ->get ( ' targets ' , $ data ['targets ' ]);
208
+ $ data ['target ' ] = $ this ->factory ->getTargets ( $ data ['targets ' ]);
202
209
}
203
210
204
- return $ this ->factory ->get ( ' action ' , $ data );
211
+ return $ this ->factory ->getAction ( $ data );
205
212
}
206
213
207
214
public function findBills (array $ data ): array
0 commit comments