Completed
Push — master ( b53e51...1009f9 )
by Alejandro
04:13 queued 38s
created

ApplicationConfigCustomizerPlugin::process()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 13
nc 2
nop 3
dl 0
loc 20
ccs 14
cts 14
cp 1
crap 4
rs 9.2
c 0
b 0
f 0
1
<?php
2
namespace Shlinkio\Shlink\CLI\Install\Plugin;
3
4
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
5
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Console\Question\ConfirmationQuestion;
9
10
class ApplicationConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin
11
{
12
    use StringUtilsTrait;
13
14
    /**
15
     * @param InputInterface $input
16
     * @param OutputInterface $output
17
     * @param CustomizableAppConfig $appConfig
18
     * @return void
19
     * @throws \Symfony\Component\Console\Exception\RuntimeException
20
     */
21 3
    public function process(InputInterface $input, OutputInterface $output, CustomizableAppConfig $appConfig)
22
    {
23 3
        $this->printTitle($output, 'APPLICATION');
24
25 3
        if ($appConfig->hasApp() && $this->questionHelper->ask($input, $output, new ConfirmationQuestion(
26
            '<question>Do you want to keep imported application config? (Y/n):</question> '
27 3
        ))) {
28 1
            return;
29
        }
30
31 2
        $appConfig->setApp([
32 2
            'SECRET' => $this->ask(
33 2
                $input,
34 2
                $output,
35 2
                'Define a secret string that will be used to sign API tokens (leave empty to autogenerate one)',
36 2
                null,
37
                true
38 2
            ) ?: $this->generateRandomString(32),
39 2
        ]);
40 2
    }
41
}
42