Skip to content

Commit 151183b

Browse files
author
Babichev Maxim
committed
Merge remote-tracking branch 'remotes/origin/master' into storable
# Conflicts: # src/Services/WalletService.php # src/WalletServiceProvider.php
2 parents b1c8bbc + 1c59b95 commit 151183b

28 files changed

+343
-50
lines changed

.phpstorm.meta.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@
77
use Bavix\Wallet\Models\Transaction;
88
use Bavix\Wallet\Models\Transfer;
99
use Bavix\Wallet\Models\Wallet;
10+
use Bavix\Wallet\Objects\Bring;
11+
use Bavix\Wallet\Objects\Cart;
12+
use Bavix\Wallet\Objects\EmptyLock;
13+
use Bavix\Wallet\Objects\Operation;
1014
use Bavix\Wallet\Services\CommonService;
1115
use Bavix\Wallet\Services\ExchangeService;
1216
use Bavix\Wallet\Services\ProxyService;
1317
use Bavix\Wallet\Services\WalletService;
1418

1519
override(\app(0), map([
20+
Cart::class => Cart::class,
21+
Bring::class => Bring::class,
22+
Operation::class => Operation::class,
23+
EmptyLock::class => EmptyLock::class,
1624
ExchangeService::class => ExchangeService::class,
1725
CommonService::class => CommonService::class,
1826
ProxyService::class => ProxyService::class,

changelog.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [3.3.0] - 2019-09-10
10+
### Added
11+
- Added the ability to easily overload the main classes #106
12+
913
## [3.2.1] - 2019-09-10
1014
### Fixed
1115
- Fixed calculation of commission for exchange #101 @haojingliu
@@ -399,7 +403,8 @@ The operation is now executed in the transaction and updates the new `refund` fi
399403
- Exceptions: AmountInvalid, BalanceIsEmpty.
400404
- Models: Transfer, Transaction.
401405

402-
[Unreleased]: https://github.com/bavix/laravel-wallet/compare/3.2.1...HEAD
406+
[Unreleased]: https://github.com/bavix/laravel-wallet/compare/3.3.0...HEAD
407+
[3.3.0]: https://github.com/bavix/laravel-wallet/compare/3.2.1...3.3.0
403408
[3.2.1]: https://github.com/bavix/laravel-wallet/compare/3.2.0...3.2.1
404409
[3.2.0]: https://github.com/bavix/laravel-wallet/compare/3.1.6...3.2.0
405410
[3.1.6]: https://github.com/bavix/laravel-wallet/compare/3.1.5...3.1.6

config/config.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
22

3+
use Bavix\Wallet\Objects\Bring;
4+
use Bavix\Wallet\Objects\Cart;
5+
use Bavix\Wallet\Objects\EmptyLock;
6+
use Bavix\Wallet\Objects\Operation;
37
use Bavix\Wallet\Services\ExchangeService;
48
use Bavix\Wallet\Services\CommonService;
59
use Bavix\Wallet\Services\ProxyService;
@@ -53,6 +57,13 @@
5357
'lock' => LockService::class,
5458
],
5559

60+
'objects' => [
61+
'bring' => Bring::class,
62+
'cart' => Cart::class,
63+
'emptyLock' => EmptyLock::class,
64+
'operation' => Operation::class,
65+
],
66+
5667
/**
5768
* Transaction model configuration.
5869
*/

src/Commands/RefreshBalance.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* Class RefreshBalance
1515
* @package Bavix\Wallet\Commands
16-
* @codeCoverageIgnore
16+
* @codeCoverageIgnore
1717
*/
1818
class RefreshBalance extends Command
1919
{

src/Objects/Cart.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class Cart implements Countable
2525

2626
/**
2727
* @return static
28+
* @deprecated use app(Cart::class)
2829
*/
2930
public static function make(): self
3031
{

src/Objects/EmptyLock.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class EmptyLock implements Lock
1616
/**
1717
* Attempt to acquire the lock.
1818
*
19-
* @param callable|null $callback
19+
* @param callable|null $callback
2020
* @return mixed
2121
*/
2222
public function get($callback = null)
@@ -31,8 +31,8 @@ public function get($callback = null)
3131
/**
3232
* Attempt to acquire the lock for the given number of seconds.
3333
*
34-
* @param int $seconds
35-
* @param callable|null $callback
34+
* @param int $seconds
35+
* @param callable|null $callback
3636
* @return bool
3737
*/
3838
public function block($seconds, $callback = null): bool

src/Services/CommonService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function forceTransfer(Wallet $from, Wallet $to, int $amount, ?array $met
5454
->getWallet($from);
5555

5656
$transfers = $this->multiBrings([
57-
(new Bring())
57+
app(Bring::class)
5858
->setStatus($status)
5959
->setDeposit($deposit)
6060
->setWithdraw($withdraw)
@@ -85,7 +85,7 @@ public function forceWithdraw(Wallet $wallet, int $amount, ?array $meta, bool $c
8585
$wallet = $walletService->getWallet($wallet);
8686

8787
$transactions = $this->multiOperation($wallet, [
88-
(new Operation())
88+
app(Operation::class)
8989
->setType(Transaction::TYPE_WITHDRAW)
9090
->setConfirmed($confirmed)
9191
->setAmount(-$amount)
@@ -115,7 +115,7 @@ public function deposit(Wallet $wallet, int $amount, ?array $meta, bool $confirm
115115
$wallet = $walletService->getWallet($wallet);
116116

117117
$transactions = $this->multiOperation($wallet, [
118-
(new Operation())
118+
app(Operation::class)
119119
->setType(Transaction::TYPE_DEPOSIT)
120120
->setConfirmed($confirmed)
121121
->setAmount($amount)

src/Services/LockService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct()
3434
*/
3535
public function lock($self, string $name, \Closure $closure)
3636
{
37-
return $this->lockProvider($self, $name, (int) config('wallet.lock.seconds'))
37+
return $this->lockProvider($self, $name, (int)config('wallet.lock.seconds'))
3838
->get($this->bindTo($self, $closure));
3939
}
4040

@@ -88,7 +88,7 @@ protected function lockProvider($self, string $name, int $seconds): Lock
8888
}
8989
// @codeCoverageIgnoreEnd
9090

91-
return new EmptyLock();
91+
return app(EmptyLock::class);
9292
}
9393

9494
}

src/Services/WalletService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function fee(Wallet $wallet, int $amount): int
3535
{
3636
$fee = 0;
3737
if ($wallet instanceof Taxable) {
38-
$fee = (int) ($amount * $wallet->getFeePercent() / 100);
38+
$fee = (int)($amount * $wallet->getFeePercent() / 100);
3939
}
4040

4141
/**

src/Traits/CanExchange.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function forceExchange(Wallet $to, int $amount, ?array $meta = null): Tra
6262
->deposit($to, $amount * $rate, $meta);
6363

6464
$transfers = app(CommonService::class)->multiBrings([
65-
(new Bring())
65+
app(Bring::class)
6666
->setStatus(Transfer::STATUS_EXCHANGE)
6767
->setDeposit($deposit)
6868
->setWithdraw($withdraw)

0 commit comments

Comments
 (0)