GenerateRsaKeys   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 54
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 21 3
1
<?php
2
3
4
namespace RichardStyles\EloquentEncryption\Console\Commands;
5
6
7
use Illuminate\Console\Command;
8
use RichardStyles\EloquentEncryption\EloquentEncryptionFacade;
9
10
class GenerateRsaKeys extends Command
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'encrypt:generate';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'This generates the application level RSA keys ' .
25
    'which are used to encrypt the application data at rest';
26
27
    /**
28
     * Create a new command instance.
29
     *
30
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
31
     */
32
    public function __construct()
33
    {
34
        parent::__construct();
35
    }
36
37
    /**
38
     * Execute the console command.
39
     *
40
     * @return mixed
41
     */
42
    public function handle()
43
    {
44
        // check for existing keys - do not overwrite
45
        if(EloquentEncryptionFacade::exists()){
46
47
            $this->warn('Application RSA keys are already set');
48
            $this->warn('**********************************************************************');
49
            $this->warn('* If you reset your keys you will lose access to any encrypted data. *');
50
            $this->warn('**********************************************************************');
51
            if ($this->confirm('Do you wish to reset your encryption keys?') === false) {
52
53
                $this->info('RSA Keys have not been overwritten');
54
55
                return;
56
            }
57
        }
58
59
        $this->info('Creating RSA Keys for Application');
60
61
        EloquentEncryptionFacade::makeEncryptionKeys();
0 ignored issues
show
Bug introduced by
The method makeEncryptionKeys() does not exist on RichardStyles\EloquentEn...loquentEncryptionFacade. Did you maybe mean encrypt()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
62
    }
63
}
64