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

GenerateSecretCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 9.4285
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