GeneratePasswordKeyCommand   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 7
c 1
b 0
f 0
dl 0
loc 30
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 1
1
<?php
2
3
namespace Benjafield\LaravelPasswordManager\Commands;
4
5
use Benjafield\LaravelPasswordManager\PasswordManager;
6
use Illuminate\Console\Command;
7
8
class GeneratePasswordKeyCommand extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'passwords:generate-key {length?}';
16
17
    /**
18
     * The description of the console command.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Generates an encryption key for the Password Manager.';
23
24
    /**
25
     * Execute the console command.
26
     *
27
     * @param PasswordManager $manager
28
     * @return int
29
     */
30
    public function handle(PasswordManager $manager)
31
    {
32
        $key = $manager->dynamicKey($this->argument('length') ?? 16);
33
34
        $this->info('Key generated successfully:');
35
        $this->line('<comment>'.$key.'</comment>');
36
37
        return 0;
38
    }
39
}