RefreshBalance::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 1
rs 10
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