Completed
Pull Request — master (#148)
by Alejandro
04:16
created

ApplicationConfigCustomizer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 94.12%

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 35
ccs 16
cts 17
cp 0.9412
rs 10
wmc 4
lcom 1
cbo 2

1 Method

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