| Conditions | 3 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3.009 |
| Changes | 0 | ||
| 1 | <?php |
||
| 40 | 28 | public function addBalance(Wallet $wallet, int $amount): bool |
|
| 41 | { |
||
| 42 | /** |
||
| 43 | * @var ProxyService $proxy |
||
| 44 | * @var \Bavix\Wallet\Models\Wallet $wallet |
||
| 45 | */ |
||
| 46 | 28 | $proxy = app(ProxyService::class); |
|
| 47 | 28 | $balance = $wallet->balance; |
|
| 48 | 28 | if ($proxy->has($wallet->getKey())) { |
|
|
|
|||
| 49 | 28 | $balance = $proxy->get($wallet->getKey()); |
|
| 50 | } |
||
| 51 | |||
| 52 | 28 | $balance += $amount; |
|
| 53 | 28 | if ($wallet->update(\compact('balance'))) { |
|
| 54 | 28 | $proxy->set($wallet->getKey(), $balance); |
|
| 55 | 28 | return true; |
|
| 56 | } |
||
| 57 | |||
| 58 | return false; |
||
| 59 | } |
||
| 62 |