1818use hiqdev \php \billing \price \PriceFactory ;
1919use hiqdev \php \billing \price \RatePrice ;
2020use hiqdev \php \billing \price \SinglePrice ;
21+ use hiqdev \php \billing \sale \SaleInterface ;
2122use hiqdev \php \billing \target \Target ;
2223use hiqdev \php \billing \tests \support \order \SimpleBilling ;
2324use hiqdev \php \billing \tests \support \tools \SimpleFactory ;
@@ -33,11 +34,12 @@ class FactoryBasedBuilder implements BuilderInterface
3334
3435 private $ plan ;
3536
36- private $ sale ;
37+ private SaleInterface $ sale ;
3738
3839 private $ prices = [];
3940
40- private $ actions = [];
41+ /** @var ActionInterface[] */
42+ private array $ actions = [];
4143
4244 private $ factory ;
4345
@@ -122,13 +124,18 @@ public function recreatePlan(string $name)
122124 $ plan ->setPrices ($ this ->prices );
123125 }
124126
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 )
126133 {
127134 $ this ->time = $ time ;
128135 $ this ->sale = $ this ->factory ->getSale (array_filter ([
129136 'customer ' => $ this ->customer ,
130137 'target ' => $ target ,
131- 'plan ' => $ plan ,
138+ 'plan ' => $ planName ,
132139 'time ' => $ time ,
133140 'closeTime ' => $ closeTime ,
134141 ]));
@@ -198,10 +205,10 @@ public function buildAction(array $data): ActionInterface
198205 $ data ['time ' ] = $ data ['time ' ] ?? $ this ->time ;
199206 $ data ['customer ' ] = $ data ['customer ' ] ?? $ this ->customer ;
200207 if (!empty ($ data ['targets ' ])) {
201- $ data ['target ' ] = $ this ->factory ->get ( ' targets ' , $ data ['targets ' ]);
208+ $ data ['target ' ] = $ this ->factory ->getTargets ( $ data ['targets ' ]);
202209 }
203210
204- return $ this ->factory ->get ( ' action ' , $ data );
211+ return $ this ->factory ->getAction ( $ data );
205212 }
206213
207214 public function findBills (array $ data ): array
0 commit comments