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

ApplicationConfigCustomizerPlugin   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 32
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 20 4
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