Completed
Push — master ( 9ab4b9...065cdd )
by Alejandro
09:44
created

GenerateSecretCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 35
ccs 0
cts 13
cp 0
rs 10
wmc 3
lcom 1
cbo 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A configure() 0 7 1
A execute() 0 5 1
1
<?php
2
namespace Shlinkio\Shlink\CLI\Command\Config;
3
4
use Acelaya\ZsmAnnotatedServices\Annotation\Inject;
5
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Zend\I18n\Translator\TranslatorInterface;
10
11
class GenerateSecretCommand extends Command
12
{
13
    use StringUtilsTrait;
14
15
    /**
16
     * @var TranslatorInterface
17
     */
18
    private $translator;
19
20
    /**
21
     * GenerateCharsetCommand constructor.
22
     * @param TranslatorInterface $translator
23
     *
24
     * @Inject({"translator"})
25
     */
26
    public function __construct(TranslatorInterface $translator)
27
    {
28
        $this->translator = $translator;
29
        parent::__construct(null);
30
    }
31
32
    public function configure()
33
    {
34
        $this->setName('config:generate-secret')
35
             ->setDescription($this->translator->translate(
36
                 'Generates a random secret string that can be used for JWT token encryption'
37
             ));
38
    }
39
40
    public function execute(InputInterface $input, OutputInterface $output)
41
    {
42
        $secret = $this->generateRandomString(32);
43
        $output->writeln($this->translator->translate('Secret key:') . sprintf(' <info>%s</info>', $secret));
44
    }
45
}
46