GenerateConfigurationCommand::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 2
dl 0
loc 14
rs 9.9
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace lepiaf\SapientBundle\Command;
5
6
use ParagonIE\Sapient\CryptographyKeys\{
7
    SigningSecretKey,
8
    SealingSecretKey
9
};
10
use Symfony\Component\Console\Command\Command;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
14
class GenerateConfigurationCommand extends Command
15
{
16
    protected function configure()
17
    {
18
        $this->setName('sapient:configure')
19
            ->setDescription('Generate configuration');
20
    }
21
22
    protected function execute(InputInterface $input, OutputInterface $output)
23
    {
24
        $signingKey = SigningSecretKey::generate();
25
        $sealKey = SealingSecretKey::generate();
26
        $output->writeln('Copy generated configuration below into sapient.yml configuration file.');
27
        $output->writeln(<<<CONFIG
28
sapient:
29
    sign:
30
        public: '{$signingKey->getPublickey()->getString()}'
31
        private: '{$signingKey->getString()}'
32
        host: ~
33
    seal:
34
        public: '{$sealKey->getPublickey()->getString()}'
35
        private: '{$sealKey->getString()}'
36
    sealing_public_keys: ~
37
    verifying_public_keys: ~
38
39
CONFIG
40
        );
41
    }
42
}
43