Completed
Push — master ( aa77c9...15a70d )
by Alejandro
27s
created

GenerateSecretCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 17
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 5 1
A execute() 0 4 1
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