Completed
Pull Request — master (#220)
by Alejandro
03:52
created

ApplicationConfigCustomizer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 25 4
1
<?php
2
declare(strict_types=1);
3
4
namespace Shlinkio\Shlink\Installer\Config\Plugin;
5
6
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
7
use Shlinkio\Shlink\Installer\Model\CustomizableAppConfig;
8
use Symfony\Component\Console\Style\SymfonyStyle;
9
10
class ApplicationConfigCustomizer implements ConfigCustomizerInterface
11
{
12
    use StringUtilsTrait;
13
14
    public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void
15
    {
16
        $io->title('APPLICATION');
17
18
        if ($appConfig->hasApp() && $io->confirm('Do you want to keep imported application config?')) {
19
            return;
20
        }
21
22
        $validator = function ($value) {
23
            return $value;
24
        };
25
        $appConfig->setApp([
26
            'SECRET' => $io->ask(
27
                'Define a secret string that will be used to sign API tokens (leave empty to autogenerate one)',
28
                null,
29
                $validator
30
            ) ?: $this->generateRandomString(32),
31
            'DISABLE_TRACK_PARAM' => $io->ask(
32
                'Provide a parameter name that you will be able to use to disable tracking on specific request to '
33
                . 'short URLs (leave empty and this feature won\'t be enabled)',
34
                null,
35
                $validator
36
            ),
37
        ]);
38
    }
39
}
40