ScaffoldCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 57
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 20 2
1
<?php
2
3
namespace Lacasera\ApiJwtScaffold\Console;
4
5
use Illuminate\Console\Command;
6
use Lacasera\ApiJwtScaffold\ApiJwtScaffold;
7
8
class ScaffoldCommand extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'make:auth-api';
16
17
    protected $packages = [
18
        'laravel-passport',
19
        'tymon-jwt'
20
    ];
21
22
    /**
23
     * The console command description.
24
     *
25
     * @var string
26
     */
27
    protected $description = 'Scaffold api jwt authentication';
28
29
    /**
30
     * Create a new command instance.
31
     */
32
    public function __construct()
33
    {
34
        parent::__construct();
35
    }
36
37
    /**
38
     * Execute the console command.
39
     *
40
     * @param ApiJwtScaffold $apiJwtScaffold
41
     * @return mixed
42
     * @throws \Exception
43
     */
44
    public function handle(ApiJwtScaffold $apiJwtScaffold): void
45
    {
46
        $packageToUse = $this->choice(
47
            'which package will you like to use ?',
48
            $this->packages,
49
            $this->packages[0]
50
        );
51
52
        $confirmed = $this->confirm('This action may override existing auth configurations. Do you want to proceed?');
53
54
        if (!$confirmed) {
55
            $this->info('Scaffolding aborted');
56
        }
57
58
        $this->info("Scaffolding your api auth using $packageToUse. Please wait..");
59
60
        $this->info($apiJwtScaffold->setup($packageToUse));
61
62
        $this->info('Authentication scaffolding generated successfully. Happy Hacking');
63
    }
64
}
65