Completed
Push — master ( 2bc6ba...1ab902 )
by Francesco
09:17
created

SecretGeneratorCommand::writeResults()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
3
/*
4
 * This file is part of the MesCryptoBundle package.
5
 *
6
 * (c) Francesco Cartenì <http://www.multimediaexperiencestudio.it/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Mes\Security\CryptoBundle\Command;
13
14
use Mes\Security\CryptoBundle\Utils\SecretGenerator;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
/**
19
 * Class SecretGeneratorCommand.
20
 */
21
class SecretGeneratorCommand extends AbstractCommand
22
{
23
    /**
24
     * @var SecretGenerator
25
     */
26
    private $generator;
27
28 1
    public function __construct(SecretGenerator $generator)
29
    {
30 1
        $this->generator = $generator;
31
32 1
        parent::__construct();
33 1
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 1
    protected function configure()
39
    {
40 1
        $this->setName('mes:crypto:generate-secret')
41 1
             ->setDescription('Generates an authentication secret')
42 1
             ->setHelp(<<<'EOF'
43 1
The <info>%command.name%</info> generates an authentication secret.
44
45
<info>%command.full_name%</info>
46
EOF
47
             );
48 1
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 1
    protected function execute(InputInterface $input, OutputInterface $output)
54
    {
55 1
        $this->writeResults($output, array(
56 1
            'secret' => $this->generator->generateRandomSecret(),
57
        ));
58 1
    }
59
60
    /**
61
     * @param OutputInterface $output
62
     * @param $options
63
     *
64
     * @return string
65
     */
66 1
    protected function writeResults(OutputInterface $output, $options)
67
    {
68 1
        $output->write($options['secret']);
69 1
    }
70
}
71