RefreshBalance   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 6
c 2
b 0
f 1
dl 0
loc 25
ccs 2
cts 2
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 5 1
1
<?php
2
3
namespace Bavix\Wallet\Commands;
4
5
use Bavix\Wallet\Models\Wallet;
6
use Bavix\Wallet\Services\DbService;
7
use Illuminate\Console\Command;
8
9
/**
10
 * Class RefreshBalance.
11
 */
12
class RefreshBalance extends Command
13
{
14
    /**
15
     * The name and signature of the console command.
16
     *
17
     * @var string
18
     */
19
    protected $signature = 'wallet:refresh';
20
21
    /**
22
     * The console command description.
23
     *
24
     * @var string
25
     */
26
    protected $description = 'Recalculates all wallets';
27
28
    /**
29
     * @return void
30
     * @throws
31
     */
32 2
    public function handle(): void
33
    {
34
        app(DbService::class)->transaction(static function () {
35
            Wallet::query()->each(static function (Wallet $wallet) {
36 2
                $wallet->refreshBalance();
37 2
            });
38 2
        });
39 2
    }
40
}
41