Completed
Pull Request — master (#278)
by Alejandro
02:43
created

GenerateSecretCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Shlinkio\Shlink\CLI\Command\Config;
5
6
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Symfony\Component\Console\Style\SymfonyStyle;
11
use function sprintf;
12
13
class GenerateSecretCommand extends Command
14
{
15
    use StringUtilsTrait;
16
17
    public const NAME = 'config:generate-secret';
18
19
    protected function configure(): void
20
    {
21
        $this
22
            ->setName(self::NAME)
23
            ->setDescription('[DEPRECATED] Generates a random secret string that can be used for JWT token encryption');
24
    }
25
26
    protected function execute(InputInterface $input, OutputInterface $output): void
27
    {
28
        $secret = $this->generateRandomString(32);
29
        (new SymfonyStyle($input, $output))->success(sprintf('Secret key: "%s"', $secret));
30
    }
31
}
32