Passed
Push — hypernext ( 922df8...ebdfc9 )
by Nico
10:06
created

GenSecretKey::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 9
rs 10
1
<?php declare(strict_types=1);
2
/**
3
 * @author Nicolas CARPi <[email protected]>
4
 * @copyright 2012 Nicolas CARPi
5
 * @see https://www.elabftw.net Official website
6
 * @license AGPL-3.0
7
 * @package elabftw
8
 */
9
10
namespace Elabftw\Commands;
11
12
use Defuse\Crypto\Key;
13
use Symfony\Component\Console\Command\Command;
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Output\OutputInterface;
16
17
/**
18
 * Generate secret key locally
19
 */
20
class GenSecretKey extends Command
21
{
22
    // the name of the command (the part after "bin/console")
23
    protected static $defaultName = 'genkey';
24
25
    /**
26
     * Set the help messages
27
     */
28
    protected function configure(): void
29
    {
30
        $this
31
            // the short description shown while running "php bin/console list"
32
            ->setDescription('Generate the secret key for the application')
33
34
            // the full command description shown when running the command with
35
            // the "--help" option
36
            ->setHelp('The secret key is used to encrypt smtp password among other things. It needs to be in a particular format.');
37
    }
38
39
    protected function execute(InputInterface $input, OutputInterface $output): int
40
    {
41
        $output->writeln(Key::createNewRandomKey()->saveToAsciiSafeString());
42
        return 0;
43
    }
44
}
45