Skip to content

Commit 3642914

Browse files
committed
update doc contracts
1 parent a580a40 commit 3642914

File tree

2 files changed

+76
-9
lines changed

2 files changed

+76
-9
lines changed

src/Interfaces/Customer.php

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Bavix\Wallet\Exceptions\InsufficientFunds;
99
use Bavix\Wallet\Exceptions\ProductEnded;
1010
use Bavix\Wallet\Internal\Exceptions\ExceptionInterface;
11+
use Bavix\Wallet\Internal\Exceptions\ModelNotFoundException;
1112
use Bavix\Wallet\Internal\Exceptions\TransactionFailedException;
1213
use Bavix\Wallet\Models\Transfer;
1314
use Illuminate\Database\RecordsNotFoundException;
@@ -36,7 +37,7 @@ public function forceRefund(Product $product, bool $gifts = false): bool;
3637
* @throws TransactionFailedException
3738
* @throws ExceptionInterface
3839
*
39-
* @return Transfer[]
40+
* @return non-empty-array<Transfer>
4041
*/
4142
public function payFreeCart(CartInterface $cart): array;
4243

@@ -48,23 +49,58 @@ public function payFreeCart(CartInterface $cart): array;
4849
* @throws TransactionFailedException
4950
* @throws ExceptionInterface
5051
*
51-
* @return Transfer[]
52+
* @return non-empty-array<Transfer>
5253
*/
5354
public function payCart(CartInterface $cart, bool $force = false): array;
5455

55-
/**
56-
* @return Transfer[]
57-
*/
56+
/** @return Transfer[] */
5857
public function safePayCart(CartInterface $cart, bool $force = false): array;
5958

6059
/**
61-
* @return Transfer[]
60+
* @throws ProductEnded
61+
* @throws RecordsNotFoundException
62+
* @throws TransactionFailedException
63+
* @throws ExceptionInterface
64+
*
65+
* @return non-empty-array<Transfer>
6266
*/
6367
public function forcePayCart(CartInterface $cart): array;
6468

69+
/**
70+
* @throws BalanceIsEmpty
71+
* @throws InsufficientFunds
72+
* @throws RecordsNotFoundException
73+
* @throws TransactionFailedException
74+
* @throws ModelNotFoundException
75+
* @throws ExceptionInterface
76+
*/
6577
public function refundCart(CartInterface $cart, bool $force = false, bool $gifts = false): bool;
6678

6779
public function safeRefundCart(CartInterface $cart, bool $force = false, bool $gifts = false): bool;
6880

81+
/**
82+
* @throws RecordsNotFoundException
83+
* @throws TransactionFailedException
84+
* @throws ModelNotFoundException
85+
* @throws ExceptionInterface
86+
*/
6987
public function forceRefundCart(CartInterface $cart, bool $gifts = false): bool;
88+
89+
/**
90+
* @throws BalanceIsEmpty
91+
* @throws InsufficientFunds
92+
* @throws RecordsNotFoundException
93+
* @throws TransactionFailedException
94+
* @throws ModelNotFoundException
95+
* @throws ExceptionInterface
96+
*/
97+
public function refundGiftCart(CartInterface $cart, bool $force = false): bool;
98+
99+
/**
100+
* @throws RecordsNotFoundException
101+
* @throws TransactionFailedException
102+
* @throws ModelNotFoundException
103+
* @throws ExceptionInterface
104+
*/
105+
public function forceRefundGiftCart(CartInterface $cart): bool;
70106
}

src/Traits/CartPay.php

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ public function payFreeCart(CartInterface $cart): array
7272
});
7373
}
7474

75-
/**
76-
* @return Transfer[]
77-
*/
75+
/** @return Transfer[] */
7876
public function safePayCart(CartInterface $cart, bool $force = false): array
7977
{
8078
try {
@@ -128,6 +126,11 @@ public function payCart(CartInterface $cart, bool $force = false): array
128126
}
129127

130128
/**
129+
* @throws ProductEnded
130+
* @throws RecordsNotFoundException
131+
* @throws TransactionFailedException
132+
* @throws ExceptionInterface
133+
*
131134
* @return non-empty-array<Transfer>
132135
*/
133136
public function forcePayCart(CartInterface $cart): array
@@ -144,6 +147,14 @@ public function safeRefundCart(CartInterface $cart, bool $force = false, bool $g
144147
}
145148
}
146149

150+
/**
151+
* @throws BalanceIsEmpty
152+
* @throws InsufficientFunds
153+
* @throws RecordsNotFoundException
154+
* @throws TransactionFailedException
155+
* @throws ModelNotFoundException
156+
* @throws ExceptionInterface
157+
*/
147158
public function refundCart(CartInterface $cart, bool $force = false, bool $gifts = false): bool
148159
{
149160
return app(DatabaseServiceInterface::class)->transaction(function () use ($cart, $force, $gifts) {
@@ -194,6 +205,12 @@ public function refundCart(CartInterface $cart, bool $force = false, bool $gifts
194205
});
195206
}
196207

208+
/**
209+
* @throws RecordsNotFoundException
210+
* @throws TransactionFailedException
211+
* @throws ModelNotFoundException
212+
* @throws ExceptionInterface
213+
*/
197214
public function forceRefundCart(CartInterface $cart, bool $gifts = false): bool
198215
{
199216
return $this->refundCart($cart, true, $gifts);
@@ -208,11 +225,25 @@ public function safeRefundGiftCart(CartInterface $cart, bool $force = false): bo
208225
}
209226
}
210227

228+
/**
229+
* @throws BalanceIsEmpty
230+
* @throws InsufficientFunds
231+
* @throws RecordsNotFoundException
232+
* @throws TransactionFailedException
233+
* @throws ModelNotFoundException
234+
* @throws ExceptionInterface
235+
*/
211236
public function refundGiftCart(CartInterface $cart, bool $force = false): bool
212237
{
213238
return $this->refundCart($cart, $force, true);
214239
}
215240

241+
/**
242+
* @throws RecordsNotFoundException
243+
* @throws TransactionFailedException
244+
* @throws ModelNotFoundException
245+
* @throws ExceptionInterface
246+
*/
216247
public function forceRefundGiftCart(CartInterface $cart): bool
217248
{
218249
return $this->refundGiftCart($cart, true);

0 commit comments

Comments
 (0)