1212use Bavix \Wallet \Internal \Exceptions \TransactionFailedException ;
1313use Bavix \Wallet \Models \Transaction ;
1414use Bavix \Wallet \Models \Transfer ;
15+ use Illuminate \Database \Eloquent \Model ;
1516use Illuminate \Database \Eloquent \Relations \HasMany ;
1617use Illuminate \Database \Eloquent \Relations \MorphMany ;
1718use Illuminate \Database \RecordsNotFoundException ;
1819
1920interface Wallet
2021{
2122 /**
22- * Deposit the specified amount of money into the wallet.
23- *
24- * @param int|non-empty-string $amount The amount to deposit.
25- * @param array<mixed>|null $meta Additional information for the transaction.
26- * @param bool $confirmed Whether the transaction is confirmed or not.
27- * @return Transaction The created transaction.
23+ * @param int|non-empty-string $amount
24+ * @param array<mixed>|null $meta
2825 *
2926 * @throws AmountInvalid If the amount is invalid.
3027 * @throws RecordsNotFoundException If the wallet is not found.
@@ -34,12 +31,8 @@ interface Wallet
3431 public function deposit (int |string $ amount , ?array $ meta = null , bool $ confirmed = true ): Transaction ;
3532
3633 /**
37- * Withdraw the specified amount of money from the wallet.
38- *
39- * @param int|non-empty-string $amount The amount to withdraw.
40- * @param array<mixed>|null $meta Additional information for the transaction.
41- * @param bool $confirmed Whether the transaction is confirmed or not.
42- * @return Transaction The created transaction.
34+ * @param int|non-empty-string $amount
35+ * @param array<mixed>|null $meta
4336 *
4437 * @throws AmountInvalid If the amount is invalid.
4538 * @throws BalanceIsEmpty If the balance is empty.
@@ -51,12 +44,8 @@ public function deposit(int|string $amount, ?array $meta = null, bool $confirmed
5144 public function withdraw (int |string $ amount , ?array $ meta = null , bool $ confirmed = true ): Transaction ;
5245
5346 /**
54- * Forced to withdraw funds from the wallet.
55- *
56- * @param int|non-empty-string $amount The amount to withdraw.
57- * @param array<mixed>|null $meta Additional information for the transaction.
58- * @param bool $confirmed Whether the transaction is confirmed or not.
59- * @return Transaction The created transaction.
47+ * @param int|non-empty-string $amount
48+ * @param array<mixed>|null $meta
6049 *
6150 * @throws AmountInvalid If the amount is invalid.
6251 * @throws RecordsNotFoundException If the wallet is not found.
@@ -66,12 +55,8 @@ public function withdraw(int|string $amount, ?array $meta = null, bool $confirme
6655 public function forceWithdraw (int |string $ amount , ?array $ meta = null , bool $ confirmed = true ): Transaction ;
6756
6857 /**
69- * Transfer funds from this wallet to another.
70- *
71- * @param self $wallet The wallet to transfer funds to.
72- * @param int|non-empty-string $amount The amount to transfer.
73- * @param ExtraDtoInterface|array<mixed>|null $meta Additional information for the transaction.
74- * @return Transfer The created transaction.
58+ * @param int|non-empty-string $amount
59+ * @param ExtraDtoInterface|array<mixed>|null $meta
7560 *
7661 * @throws AmountInvalid If the amount is invalid.
7762 * @throws BalanceIsEmpty If the balance is empty.
@@ -83,17 +68,8 @@ public function forceWithdraw(int|string $amount, ?array $meta = null, bool $con
8368 public function transfer (self $ wallet , int |string $ amount , ExtraDtoInterface |array |null $ meta = null ): Transfer ;
8469
8570 /**
86- * Safely transfers funds from this wallet to another.
87- *
88- * This method attempts to transfer funds from this wallet to another wallet.
89- * If an error occurs during the process, null is returned.
90- *
91- * @param self $wallet The wallet to transfer funds to.
92- * @param int|non-empty-string $amount The amount to transfer.
93- * @param ExtraDtoInterface|array<mixed>|null $meta Additional information for the transaction.
94- * This can be an instance of an ExtraDtoInterface
95- * or an array of arbitrary data.
96- * @return null|Transfer The created transaction, or null if an error occurred.
71+ * @param int|non-empty-string $amount
72+ * @param ExtraDtoInterface|array<mixed>|null $meta
9773 *
9874 * @throws AmountInvalid If the amount is invalid.
9975 * @throws BalanceIsEmpty If the balance is empty.
@@ -109,18 +85,8 @@ public function safeTransfer(
10985 ): ?Transfer ;
11086
11187 /**
112- * Forces a transfer of funds from this wallet to another, bypassing certain safety checks.
113- *
114- * This method is intended for use in scenarios where a transfer must be completed regardless of
115- * the usual validation checks (e.g., sufficient funds, wallet status). It is critical to use this
116- * method with caution as it can result in negative balances or other unintended consequences.
117- *
118- * @param self $wallet The wallet instance to which funds will be transferred.
119- * @param int|non-empty-string $amount The amount of funds to transfer. Can be specified as an integer or a string.
120- * @param ExtraDtoInterface|array<mixed>|null $meta Additional metadata associated with the transfer. This
121- * can be used to store extra information about the transaction, such as reasons for the transfer or
122- * identifiers linking to other systems.
123- * @return Transfer Returns a Transfer object representing the completed transaction.
88+ * @param int|non-empty-string $amount
89+ * @param ExtraDtoInterface|array<mixed>|null $meta
12490 *
12591 * @throws AmountInvalid If the amount specified is invalid (e.g., negative values).
12692 * @throws RecordsNotFoundException If the target wallet cannot be found.
@@ -136,60 +102,34 @@ public function forceTransfer(
136102 ): Transfer ;
137103
138104 /**
139- * Checks if the wallet can safely withdraw the specified amount.
140- *
141- * @param int|non-empty-string $amount The amount to withdraw.
142- * @param bool $allowZero Whether to allow withdrawing when the balance is zero.
143- * @return bool Returns true if the wallet can withdraw the specified amount, false otherwise.
105+ * @param int|non-empty-string $amount
144106 */
145107 public function canWithdraw (int |string $ amount , bool $ allowZero = false ): bool ;
146108
147109 /**
148- * Returns the balance of the wallet as a string.
149- *
150- * The balance is the total amount of funds held by the wallet.
151- *
152- * @return non-empty-string The balance of the wallet.
110+ * @return non-empty-string
153111 */
154112 public function getBalanceAttribute (): string ;
155113
156- /**
157- * Returns the balance of the wallet as an integer.
158- *
159- * @return int The balance of the wallet. This value is the result of
160- * {@see getBalanceAttribute()} converted to an integer.
161- */
162114 public function getBalanceIntAttribute (): int ;
163115
164116 /**
165- * Represents a relationship where a wallet has many transactions.
166- *
167- * @return HasMany<Transaction> A collection of transactions associated with this wallet.
117+ * @return HasMany<Transaction, self>
168118 */
169119 public function walletTransactions (): HasMany ;
170120
171121 /**
172- * Returns all the transactions associated with this wallet.
173- *
174- * This method returns a morph many relationship that represents all the transactions
175- * associated with this wallet. The transactions may be of different types, such as
176- * deposits, withdrawals, or transfers.
177- *
178- * @return MorphMany<Transaction> A collection of transactions associated with this wallet.
122+ * @return MorphMany<Transaction, Model>
179123 */
180124 public function transactions (): MorphMany ;
181125
182126 /**
183- * Returns all the transfers sent by this wallet.
184- *
185- * @return HasMany<Transfer> A collection of transfers sent by this wallet.
127+ * @return HasMany<Transfer, self>
186128 */
187129 public function transfers (): HasMany ;
188130
189131 /**
190- * Returns all the transfers received by this wallet.
191- *
192- * @return HasMany<Transfer> A collection of transfers received by this wallet.
132+ * @return HasMany<Transfer, self>
193133 */
194134 public function receivedTransfers (): HasMany ;
195135}
0 commit comments