CacheRefreshCommand::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 9
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
crap 2
1
<?php
2
3
namespace MadWeb\SocialAuth\Console;
4
5
use Illuminate\Console\Command;
6
use MadWeb\SocialAuth\SocialProvidersLoader;
7
8
class CacheRefreshCommand extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'social-auth:refresh';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Refresh social auth providers cache';
23
24
    /**
25
     * @var SocialProvidersLoader
26
     */
27
    protected $loader;
28
29
    /**
30
     * CacheRefreshCommand constructor.
31
     * @param SocialProvidersLoader $loader
32
     */
33
    public function __construct(SocialProvidersLoader $loader)
34
    {
35
        parent::__construct();
36
37
        $this->loader = $loader;
38
    }
39
40
    /**
41
     * Execute the console command.
42
     *
43
     * @return void
44
     */
45
    public function handle()
46
    {
47
        $this->loader->forgetSocialProviders();
48
        $providers = $this->loader->getSocialProviders();
49
50
        $this->info(
51
            'Cache was refreshed. Current available social providers: '.
52
            $providers->implode('label', ', ')
53
        );
54
    }
55
}
56