RestockCredits   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 10 2
1
<?php
2
3
namespace App\Console\Commands;
4
5
use App\Token;
6
use Illuminate\Console\Command;
7
use Log;
8
9
class RestockCredits extends Command
10
{
11
    /**
12
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'siwecos:restock';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Restock credits to 50';
24
25
    /**
26
     * Create a new command instance.
27
     *
28
     * @return void
29
     */
30
    public function __construct()
31
    {
32
        parent::__construct();
33
    }
34
35
    /**
36
     * Execute the console command.
37
     *
38
     * @return mixed
39
     */
40
    public function handle()
41
    {
42
        /** @var Token[] $allCreditsBelow */
43
        $allCreditsBelow = Token::where('credits', '<', 50)->get();
44
45
        foreach ($allCreditsBelow as $token) {
46
            $this->info('Restock credits for token: '.$token->token);
47
            Log::info('Restock credits for token: '.$token->token);
48
            $token->credits = 50;
49
            $token->save();
50
        }
51
    }
52
}
53